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?

  • Detect if my app runs in Azure
  • How to send configurations to docker container? [closed]
  • Why does creating a file inside a docker-machine VM result in permission denied?
  • can not ping as normal user in Docker centos image
  • Unable to find error in my script doesn't behave as intended
  • Docker creating a new image with an added Java application
  • Java JVM on Docker/CoreOS
  • how to cross docker-compose.yml file to link container
  • docker run registry error 301 response missing Location header
  • Got errors with ONBUILD options (Docker toolbox in Windows)
  • Download BAIR-trained Caffe Model Using Script
  • Configuration issue in nginx of docker - Troubleshooting docker with no instaces
  • 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.