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 :

  • Docker + ELK stack taking up more space than it should
  • Hot to enable swarm containers to connect to the host machine?
  • Graylog docker container only binds when it listens to 0.0.0.0 and not 127.0.0.1?
  • docker: how to show the diffs between 2 images
  • Docker - dynamic regex-based sed substitution in files
  • On kubernetes helm how to replace a pod with new config values
  • version: '2'
    
    services:
        myapp:
            build: ./dockerfiles/myapp
            volumes:
              - ./www:/var/www
              - ./logs:/var/log
              - ./mysql-data:/var/lib/mysql
              - ./php:/etc/php5
              - ./nginx:/etc/nginx
            ports:
                - "8082:8000"
                - "6606:3306"
            links:
                - mysql:mysql
                - php:php
                - nginx:nginx
        mysql:
            image: mysql
            environment:
                MYSQL_ROOT_PASSWORD: M@yW3Bw35t
                MYSQL_USER: replymwp
                MYSQL_PASSWORD: ZSzLPoOi9wlhFaiJ
        php:
            image: php:5.6-fpm
            links:
                - mysql:db
        nginx:
            image: nginx
            links:
                - 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 http://repo.ajenti.org/debian/key -O- | apt-key add -
    RUN echo "deb http://repo.ajenti.org/ng/debian 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.

  • Integrating Docker with Xdebug and Sublime Text on PHP environment
  • Can I select which services to run with Atlassian's Localstack
  • Travis Multi-Architecture Buiilds
  • How can I install docker toolbox on windows 7
  • docker -v and symlinks
  • Docker - Running Apache and Multiple JARs
  • 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.