No access to a linked container with docker run (mapping in /etc/hosts not exist)

I have a running mysql container with name “drupaldistribution_mysql_1” (id 307b58c78108).

Now I want to start another container with a command tool named “drush”, that has access to the mysql container. I use the command:

  • Run multiple containers on same docker network localhost
  • Nginx service on Docker giving better performance on 1GB RAM Node than 4GB RAM Node
  • Deploying .NET Core 1.1 App to Docker - Could not resolve CoreCLR path
  • How can I create a stream for DockerDotNet BuildImageFromDockerfile method?
  • Is the Docker engine installed on the server or client?
  • How to pass parameter into docker container and update file in container with passed parameter
  • $ docker run --link 307b58c78108:db --volumes-from drupaldistribution_data_1 -w /data/www/drupal drush/drush sqlc && cat /etc/hosts
    

    But the /etc/hosts file in the drush container does not contain the information about the linked container:

    127.0.0.1   localhost
    127.0.1.1 docker-host docker-host
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    

    Docker inspect on the drush container returns:

    $ docker inspect -f "{{ .HostConfig.Links }}" 7d5f4cea983e
    
    [/drupaldistribution_mysql_1:/tender_banach/db]
    

    I run the docker version: Docker version 1.6.2, build 7c8fca2 (inside of vagrant debian machine).

    Why is there no reference in the hosts file about the linked mysql container?

  • GO - Local import not working
  • Error running openshift/origin docker: Error running 'chcon' to set the kubelet volume root directory SELinux context
  • Using Docker for development and sharing dependencies for features such as IDE auto-completion
  • Must I provide a command when running a docker container?
  • Import data on mongodb from docker-compose
  • How i can install Actor Platform with Docker
  • One Solution collect form web for “No access to a linked container with docker run (mapping in /etc/hosts not exist)”

    My guess is the issue is due to the --volumes-from. Try not to share data between your database and other containers.
    When I try, I have the 127.0.1.1 docker-host docker-host line though is it part of your local /etc/hosts?

    Also, you can use the name with --link instead of the id.

    Finally, if it still fails, you always can pull the ip from the environment. Make sure that your mysql image exposes a port and once you link it, you will have DB_PORT_XXXX_TCP_ADDR in the environment.

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