At the moment I\'m running a node.js application inside a docker container which needs to connect to camunda, which runs in another container.
I start the container
Original answer below. Note that link has been deprecated and the recommended replacement is network. That is explained in the answer to this question: docker-compose: difference between network and link
--
Use the --link camunda:camunda
option for your app container. Then you can access camunda via http://camunda:8080/...
. The link option adds a entry to the /etc/hosts
file of the app container with the IP address of the camunda container. This also means you have to restart your app container if you restart the camunda container.
Containers and host do not share their local IP stack. Thus, when you are within a container and try anything localhost:port
the anything
command will try to connect to the container-specific local IP stack, not the other container nor the host.
Hard way: you either need to know the IP address of the other container and connect to this IP address..
Easier and cleaner way: .. either link your containers.
--link=[] Add link to another container in the form of <name or id>:alias or just <name or id> in which case the alias will match the name
So you'll need to perform, assuming the camunda container is named camunda:
docker run -d --name app -p 3000:3000 --link camunda app
Then, once you docker-exec
-ed into the container app you will be able to execute wget http://camunda:8080 -q -O -
without error.
Note that while the linked containers graph cannot loop, e.g., camunda cannot be linked to app as you need to start a container to be able to link it, you actually do whatever you want/need playing with IP addresses.
Note also that you can specify the IP address of a container using the --ip
option (though it can only be used in conjunction with --net
for user-defined networks).