Inter-container connection via localhost

I would like to set up my containers so that they connect to each other via localhost.

My setup is a main application container and two other containers that it needs to connect to (ActiveMQ and Wiremock).

  • Download all dependencies, plugin dependencies, compilers, etc. with Maven?
  • Docker: how do I find localhost's password on Windows 8.1
  • 404 while serving static files via docker nginx
  • Accessing host usb device in docker for windows
  • Fixed issue with connecting to docker but don't know why the fix worked
  • Ansible: 'item' is undefined
  • I already run ActiveMQ and Wiremock in containers with the relevant ports exposed, and the main application runs through IntelliJ and connects to these. However, when I am not developing the main applications, I would like to run it in a container for simplicity but it cannot connect to the ports exposed by the others.

    Setting --net=host doesn’t seem to work, nor does creating a network docker network create <NAME> and assigning it in the docker run with --net=<NAME>.

    The application already runs in a container in other environments on the host network.

  • Virtualbox inside Docker
  • Noob FED tries to run MeanJS app on docker port mapping throws error
  • Setting TLS opptions for Docker as Environment Variables
  • Running Docker container randomly disappears on AWS EC2 Ubuntu
  • Oracle impdp running way too long
  • Docker GCE, Layer already being pulled by another client. Waiting
  • One Solution collect form web for “Inter-container connection via localhost”

    docker creates a default network in which all containers run, and sets a network name for each of your containers, using the container name.

    if you have a contained named mq for your ActiveMQ, then you would use something like tcp://mq:61616 (or whatever protocol / port you have configured) from your other containers, to connect to it.

    you shouldn’t need to set the --net option unless you need to create a specific network for specific containers to use.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.