Docker for Mac Beta: Unable to link containers properly

I have tried linking two containers and executing commands valid on one from the other which works in the docker toolbox version of the tool.

Copy of YML file:

  • Accessing a MySql database from external IP (Docker containers)
  • Use github private repo deploy key inside build stage in docker for npm install
  • unable to invoke docker container
  • Docker nginx error at mounting config file
  • Pycharm docker remote python interpreter
  • how to install global angular-cli inside docker container?
  • version: '2'
         image: nginx:latest
         hostname: nginx
         - php
         - "8000:80"
       privileged: true
       image: php:5-fpm
       hostname: php
       privileged: true

    I expect to be able to log onto the nginx container and be able to execute php i.e. php -version.

    docker exec -it test2_nginx_1 bash
    root@nginx:/# ping php
    PING php ( 56 data bytes
    64 bytes from icmp_seq=0 ttl=64 time=0.103 ms
    64 bytes from icmp_seq=1 ttl=64 time=0.089 ms

    Ping works!

    root@nginx:/# php -version
    bash: php: command not found

    This does not work.

    Logging on to the php container:

    docker exec -it test2_php_1 bash
    root@php:/var/www/html# php -version
    PHP 5.6.22 (cli) (built: Jun  8 2016 17:49:08)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

    Why am I not able to execute it on the linked container?

  • Clashing between two postgres database though having two different docker-compose yaml files for django projects
  • Unable to register Docker service with Registrator
  • standard_init_linux.go:178: exec user process caused “no such file or directory”
  • Single file volume mounted as directory in Docker
  • How do I setup a docker image to dynamically pull app code from a repository?
  • pytest: environment variable to specify pytest.ini location
  • One Solution collect form web for “Docker for Mac Beta: Unable to link containers properly”

    Why am I not able to execute it on the linked container?

    Because “linking” (or, since docker 1.10, a common network), is about communication, not programs.

    Your nginx container is like an individual machine on which php was never installed. It can ping the php container, but not locally execute what is installed only on said php machine.

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