Host
You cannot connect to another container using localhost (since localhost is the current container), but you can connect through the host container (the host on which your container is running). In your case, you need the IP address of boot2docker VM ( echo $(boot2docker ip) ). To do this, you need to set your port at the host level (what do you do with -p 1337:1337 ).
LINK
Another solution that is most common and which I prefer when possible is container binding.
You need to add the -name flag to the docker run server docker run : --name sails_server
You need to add the -link flag to the docker run : --link sails_server:sails_server
And inside your application, you can access the server in sail_server:1337 You can also use environment variables to get the server IP address. See Documentation: https://docs.docker.com/userguide/dockerlinks/
BONUS: DOCKER COMPOSITION
Launch commands can start a little long ... in this case, I like to use docker-compose , which allows me to define my containers and their relationships (volumes, names, links, commands ...) in one file.
CΓ©line aussourd
source share