Docker-compose linking service into dockerfile

I am pretty new to docker, and I am trying to make a container with multiple apps.

Let say that my docker-compose file is like this :

  • pip install pymssql from inside docker container
  • What is a good way to add python dependencies to a Docker container?
  • Running docker-compose with mysql and own docker container
  • Searching for the most optimal solution with Django, Docker, virtualenv and structure of files [closed]
  • Validating docker v0.8 on OS X, boot2docker ssh hangs, docker version generates EOF
  • how to set supervisor to run a shell script
  • version: '2'
            build: ./dockerfiles/myapp
              - ./www:/var/www
              - ./logs:/var/log
              - ./mysql-data:/var/lib/mysql
              - ./php:/etc/php5
              - ./nginx:/etc/nginx
                - "8082:8000"
                - "6606:3306"
                - mysql:mysql
                - php:php
                - nginx:nginx
            image: mysql
                MYSQL_ROOT_PASSWORD: M@yW3Bw35t
                MYSQL_USER: replymwp
                MYSQL_PASSWORD: ZSzLPoOi9wlhFaiJ
            image: php:5.6-fpm
                - mysql:db
            image: nginx
                - php:php

    Now, in myapp DockerFile, I want to install a package that needs mysql.

    FROM debian:jessie
    RUN apt-get update
    RUN apt-get update 
    RUN apt-get install -y apt-show-versions
    RUN apt-get install -y wget 
    RUN wget -O- | apt-key add -
    RUN echo "deb main main ubuntu" >>         /etc/apt/sources.list
    RUN apt-get update 
    RUN apt-get install -y ajenti
    RUN apt-get install -y ajenti-v ajenti-v-ftp-vsftpd ajenti-v-php-fpm ajenti-v-mysql
    EXPOSE 8000
    ENTRYPOINT ["ajenti-panel"]

    Now the problem is, when docker try to build my image, it install php, mysql etc… even if I link it in my docker-compose file. And secondly, when it try to install mysql, It prompt for a master password and stay blocked at this step, even if I fill something…

    Maybe am I totally wrong in my way of using it?

    Any help would be appreciate.

  • Can't get my php container to connect to the mysql container
  • Windows Container swarm publish port and not access
  • Docker Registry vs Nexus/Artifactory
  • How to change ip address of docker0 bridge interface on Docker Toolbox
  • docker pseudo file not showing swap memory information
  • Change default Docker temp directory to host temp directory
  • 2 Solutions collect form web for “Docker-compose linking service into dockerfile”

    I suppose your ajenti has a dependency on mysql, so if you do apt-get install ajenti, it tries to satisfy that dependency. Specifically you are installing ajenti-v-mysql, which does seem to have a mysql dependency

    Because you want to run mysql seperate, you might need to do --no-install-recommends ? This is a flag voor apt-get, so you’d get something like

    apt-get install <packagename> --no-install-recommends

    This would mean you get NO dependencies, so you might need to figure out which other depenencies you need.

    The php-fpm has the same issue, I suppose that whole line which includes ajenti-v-php-fpm is a bit too much?

    If you’re planning on using separate mysql and php containers, then why are you still including the installation in the mpapp dockerfile on this line:

    RUN apt-get install -y ajenti-v ajenti-v-ftp-vsftpd ajenti-v-php-fpm ajenti-v-mysql

    If you’re going to use mysql and php containers then you don’t need them in your app. This should also take care of your second problem about being prompted for mysql password.

    Keep in mind that you will need to change the hostnames of mysql and your php configuration from your myapp configuration. I think you might be better off looking for a tutorial for setting up docker compose, you’ll have to look yourself to find the most suitable but something like this would give you a good start.

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