Reputation: 1569
Can I create a container using docker run <image>
without the --link
option and link other containers to it afterwards? If so, how do I link these containers then?
Upvotes: 9
Views: 7526
Reputation: 5455
Thats how you normally would do it. Fire up container A and start container B with --link B:resourcename
. Inside container B, you can now get to the stuff container A EXPOSE
s, with the info you can see inside the environment-variables env
(they will be named something with resourcename
in this case.
You can not do this the other way around (as I thought your question was originally about). The information the container needs to get to resources on the other is available as environment-variables. Which you cant inject into a running process (as far as I know..).
Upvotes: 3
Reputation: 3759
Of course yes,but you can only access other containers by ip (usually 172.17.1.x). You can use
docker inspect container_id
to find other containers ip.
Upvotes: 0