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:

  • Injecting the elastic beanstalk server URL into the node.js configuration using Docker
  • How to install tomcat7 in docker ?
  • How to open a shell while/after running a Docker container without overriding existing CMD?
  • Connect to rabbitmq on local host from a Docker container
  • Update docker-contanier jre timezone
  • Shutting down MySQL 4 correctly in Docker Container
  • version: '2'
    
      services:
    
        nginx:
         image: nginx:latest
         hostname: nginx
       links:
         - php
       ports:
         - "8000:80"
       privileged: true
    
     php:
       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 (172.19.0.2): 56 data bytes
    64 bytes from 172.19.0.2: icmp_seq=0 ttl=64 time=0.103 ms
    64 bytes from 172.19.0.2: 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?

  • Troubleshooting API timeout from Django+Celery in Docker Container
  • Running on runner-…-concurrent-0 via … runner for LONG time never ends
  • inotifywait in docker-container doesn't register changes
  • Docker push Windows Container Image to Google Container Registry fails with “manifest invalid”
  • Running GUI from a container on a mac resolve in “libGL error: No matching fbConfigs or visuals found”
  • docker Failed to create the host-only adapter Windows 7
  • 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.