Docker-compose network link

Docker ‘link’ feature will be deprecated as new feature ‘networking’ has been released (link). I’m making docker-compose with some containers, and it was fine with ‘link’ to connect each others(without any other commands).

Since I need to change link configuration to network, I have to make docker network before ‘docker-compose up’. Is there any docker-compose feature that making docker network automatically? Or any other way to connecting each containers with some configuration?

  • Pass “volume-driver” option to kubernetes pod
  • Unable to access Jupyter notebook in the web browser
  • How to run several separate WordPress websites using Docker containers
  • How to have multiple django requirements file mentioned in fig file for docker deployment across dev, staging and prod servers?
  • Accessing documentDB on host in docker contains
  • How can I ssh into “Web App On Linux” docker container on Azure?
  • Is it possible to mount folder from container to host machine?
  • How to select file to copy based on Docker environment variable?
  • Storring and pulling meta-information of a docker image
  • godep vendor with docker
  • Docker image for windows components
  • Addressing issues with Apache Spark application run in Client mode from Docker container
  • 2 Solutions collect form web for “Docker-compose network link”

    By default, docker-compose with a v2 yml will spin up a network for your project. Any networks you define will also be created unless you explicitly tell it otherwise. Here’s an example docker-compose.yml:

    version: '2'
        image: busybox
        command: tail -f /dev/null
        - dbnet
        image: busybox
        command: tail -f /dev/null
        - dbnet
        - appnet
        image: busybox
        command: tail -f /dev/null
        - 80
        - appnet

    And then when you spin it up, you’ll see that it creates the networks defined:

    $ docker-compose up -d
    Creating network "test_dbnet" with the default driver
    Creating network "test_appnet" with the default driver
    Creating test_app_1
    Creating test_db_1
    Creating test_proxy_1

    Note that linking containers also created an implicit dependency, so you may want to use depends_on in your yml to be explicit in any dependencies after removing your link.

    docker-compose creates a default network for your compose project on itself. You only have to migrate your compose projects to version: '2' or version: '3' of the compose yaml format. Please read how to upgrade for more information.

    With version 2 and 3, you don’t have to specify links anymore, as all services will be in the default network if you don’t explicitly specify other networks.

    UPDATE: To make 2 containers talk to each other, you can simply use the service names which will resolve to container IPs. Links are now only required if for some reason a container expects a specific name, e.g. because it is hardcoded.

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