How to use Dockerfile to link main container to a db container?

Docker has a quite convenient way to link the main container to a db container with a command like:

docker run --link db:db user/main

This is very convenient already. However, I believe it’s still clumsy compared to a command like:

  • PhpStorm mapping paths
  • how to access OSX non-storage devices from docker container
  • Connect to mysql in a docker container from the host
  • Why some entries are missing in Perl ENV hash
  • can't connect to docker container from outside
  • Golang failes to change the name of imported module
  • docker run user/ultra

    where ultra is a container that is already linking the main container to the db container.

    Is that possible that I can achieve this by writing a good Dockerfile.

    I suppose I can start the Dockerfile with

    FROM user/main 

    but how do I get the second container involved and then link them with Dockerfile?


  • Docker Exec command does not work properly
  • Installing cron via apt-get fails in a docker ubuntu:12.04 container from permissions problems
  • Can't access service outside of Docker container
  • docker toolbox: Is there a way to mount other folders than from c:\Users Windows?
  • connection between curator4 and elasticsearch running into two containers
  • Measure resource usage of Docker container on exit
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.