Docker – Access linked Container

I am currently trying to learn some docker.
As of now I have made wordpress with php and nginx running.

My Dockerfiles are pretty hard coded, they won’t work out of the box without their configs.

  • Kubernetes networking issue
  • Mesos/Marathon on EC2 agents hostnames not accessible
  • Running Gulp in Docker - not found
  • Docker kill an infinite process in a container after X amount of time
  • Docker and pip requirements
  • Communication between two containers on the same host
  • So what I am trying to do now is remove all of my volumes and use environment variables to provide the information I need to build my needed configuration files, but I am struggling with the linking of containers.

    I want to use a *.sh file as an Entrypoint to set the values I need within my configs. That’s is kind of easy and working by now.

    My Problem now is that I need to access a linked containers file system (to replace the volumes I used).

    I have a app.conf file (don’t blame it, I did’nt care for best practices or anything by now):

        server {
            server_name     _;
            root            LINKEDADRESS/ROOT_DIR;
            index           index.php index.html index.htm;
            access_log /var/log/nginx/default_access.log;
            error_log /var/log/nginx/default_error.log;
           # Pass PHP scripts to PHP-FPM
           location ~* \.php$ {
           fastcgi_index   index.php;
           fastcgi_pass    unix:LINKEDADRESS/RUND_DIR/php7-fpm.sock;
           include         fastcgi_params;
           fastcgi_param   SCRIPT_FILENAME    LINKEDADRESS/ROOT_DIR$fastcgi_script_name;

    The linked container is my php/wordpress container.
    My nginx-server need to access it’s filesystem to get wordpress visible in the browser. Setting the ROOT_DIR as a env-variable isn’t that big of a deal, but I don’t know how to get the adress of the linked container to access the files.

    I know that linking container causes the creation of some env-variables like



    but they seem to depend on the linked containers name. So, do I need to get that name from anywhere (maybe another env-variable) or is there a easier solution I didn’t think about?

    I’ve just started using docker that deep (I’ve made very simpel Dockerfiles before, but that’s totally different), so I will appreciate any explanations I get.
    I tried to show my way of thougts til now, I hope it’s not to hard to read.

    EDIT: I’ve just came across globs within bash-scripts, but I find them a bit confusing.

    echo "${!X*}

    gives me every environment variable beginning with X, but how do I get all of the variables (which is hopefully only one) ending with _PORT? I don’t get it.

  • Running Jenkins slave on different OS than master (and host)
  • Unable to start Elastic Beanstalk MultiContainer instance
  • Docker compose: Multiple isolated environments on a single host with overridable volumes and ports
  • ECS agent can not successfully pull image from ECR
  • How can I develop in docker container with intellij?
  • Building solr core in cloud mode with docker
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.