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:

  • Snapshot Options When Unable to Set Up LVM
  • Visual Studio Tools for Docker - PrepareForCompile task failed unexpectedly
  • NoClassDefFoundError in Tomcat for Abstract Class
  • Creating an ng-cli container in docker not working
  • Dockerized WSO2 Identity Server Version 2.3
  • MySQL - Galera OR Kubernetes Replication Controller?
  • 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?

    Thanks.

  • Docker initiate the connection to archive.ubuntu
  • What is the difference between docker-compose ports vs expose
  • error with Installation of rpy2 on mac
  • Docker Windows bridge ip conflict
  • How could I install the correct docker-compose version for 1.6.2
  • CLion in docker container not finding clang after install
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.