What are the steps to create a Docker image for Ubuntu 16:04, php 5.6 and apache (with Composer, Xdebug, phpunit, npm and REDIS)?

Asked

Viewed 966 times

2

I’m a beginner in Docker and I’m trying to create an image with the following specifications:

  1. The source OS has to be the original Ubuntu 16.04. I cannot use images already available in the Docker hub;
  2. Must have installed apache - latest version;
  3. You have to have php installed and some libraries installed. It has to be php 5.5.38 (ideal) or 5.X last update or 5.6.X last update.
  4. You must have installed REDIS.
  5. REDIS, APACHE and php must be available as soon as the container is created, that is, automatically initialized.
  6. The system root (/var/www/html) should point to a volume /home/username/vhosts/mysite. The host is a MAC OS.
  7. The system has to be accessed from the host browser via mysite-dev1 or mysite-dev2 or mysite-devN ...

The ultimate goal is to create an image that will be shared among all company developers.

This is the Dockerfile that I’m wearing:

FROM ubuntu:16.04

#1
RUN apt-get update
#2
RUN apt-get install -y apache2
#3
RUN apt-get install -y php5
#4
RUN apt-get install -y redis-server
#5
RUN apt-get install -y php5-redis

COPY /home/username/vhosts/mySite /var/www/html

EXPOSE 80

Next I’m finding some errors:

Operation #3, php5 is not part of the Ubuntu 16.04 package list. From this post it is found that it needs to be updated as follows:

#6
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5.6 

Operation #6, I get a mistake saying that the sudo is not recognized as a command (even if I try to run in iterative mode on the -ti terminal). Doing a search I note that the sudo is not enabled in Ubuntu16.04 image.

If I try to run without sudo via terminal (docker run -ti ...), I get a message saying that add-apt-repository unseen inserir a descrição da imagem aqui.

Making a other research about that mistake I find that add-apt-repository also not available for Ubuntu 14.04 images on Docker. And by the way tbm is not available for 16.04. The proposed solution is to run:

#7
apt-get install -y software-properties-common python-software-properties

Running this operation #7 get the following error: inserir a descrição da imagem aqui Doing another search, I think post which suggests modifying the apt.conf located in /etc/apt/apt.conf. And this is the contents of the apt directory from inside the Ubuntu 16.04 image inserir a descrição da imagem aqui.

I mean, it doesn’t have apt.conf. Doing a search on some posts encounter that apt conf. needs to be created.

My conclusion is that I must be doing something very wrong because the goal is only to install php5.6 in Ubuntu16.04.

In conclusion, one could say some tried and tested way of creating an image with the previously listed features without going through the previous steps?

UPDATE: It seems that other images are having the same problem when trying to install php version 5.6.

  • A container should not have all these elements. REDIS, PHP, APACHE are 3 containers. Unlike a VM, with Docker we’re talking about PROCESS virtualization, not virtual machines, so what you’re looking for, it shouldn’t be done that way. I have prepared a wiki with this doubt, it is very recurrent | https://github.com/luizcarlosfaria/kb/wiki/FAQ-Docker-LAMP

  • Luiz, I agree 100% with you. As I said, I am still beginner in Docker, but not in systems architecture. I think Docker follows the idea of microservices going further to the extreme. As you said, even sending the server to one container and php to the other. The problem is that sometimes in a company the decision is not made by one person and until everyone can understand the benefits of containers with unique functions takes a while. I liked your post. I already copied the link to my Fullstack Update group.

  • For my question, I ended up using an official Php image of Docker Hub, already ready that already has php and apache on Linux, although it is not Ubuntu. https://hub.docker.com/_/php/

  • the question of having several distinct processes like redis and php in the same container, there is no question as "depends" or "depending on the scenario", is categorically wrong. This type of approach is abhorred by simple Ocker architecture reasons. Docker uses kernel Features to abstract PROCESS isolation only. We’re not talking about a virtual Nvironment, we’re talking about a virtual process. And that completely changes the bias of the thing. In any OS you would have a Redis installation, another PHP installation (even if on the same machine)

  • ... Each element is independent, even on the same machine. The point is that Docker works like this too. The fact is that if you create an image with 2 things, such as PHP and NGINX that at first glance may even be something like that: it is wrong. PHP is php, Nginx is Nginx. Doing anything different, you will have problems with dying containers for no reason, low reuse of images and layers, overlapping responsibility. Anyway, you’re gonna have a lot of problems.

  • Understood and I agree with you Luiz. As I work more with Docker I understand his ideology. My next version will no longer have REDIS docked in the container.

Show 1 more comment

1 answer

0

Although Docker’s ideology is to individualize to the maximum the processes running each of them in different containers, I will post here my solution with REDIS within a single container.

Note @Luiz Carlos notes. Using REDIS within the same container running php, apache, etc, is not good practice.

The Dockerfile: Prepared with php 5.6, Apache, Phpunit, Xdebug, REDIS, Composer, NPM.

FROM php:5-apache

## Update apt-get
RUN apt-get update

RUN apt-get install -y figlet

RUN figlet Docker_Build

## UTILITIES
RUN figlet vim
RUN apt-get install -y vim
RUN figlet wget
RUN apt-get install -y wget
RUN figlet CURL
RUN apt-get install -y curl

##===================================================== > ffmpeg stufs

## NOTE: Debian Jessie and later no longer include the ffmpeg, however you have 3 options for installing ffmpeg // https://superuser.com/questions/286675/how-to-install-ffmpeg-on-debian

## list of installed library packages only =>  https://askubuntu.com/questions/434154/how-to-get-the-list-of-installed-library-packages-only
#ldconfig -v                # -v it will show the libraries versions
#ldconfig -v | grep libname # Use grep to find a specific library by name.
#RUN /sbin/ldconfig -p

## Installed 
#RUN figlet
#RUN apt-get install -y libav-tools

## https://superuser.com/questions/286675/how-to-install-ffmpeg-on-debian
#root@b6a73f142787:/var/www/html# apt-cache search ffmpeg => List all plugins associated with ffmpeg

#cmus-plugin-ffmpeg - lightweight ncurses audio player (FFmpeg plugin)
RUN figlet cmus
RUN apt-get install -y cmus

#ffmpeg2theora - Theora video encoder using ffmpeg
RUN figlet ffmpeg2theora
RUN apt-get install -y ffmpeg2theora

#ffmpegthumbnailer - fast and lightweight video thumbnailer
RUN figlet ffmpegthumbnailer
RUN apt-get install -y ffmpegthumbnailer

#ffmpegthumbnailer-dbg - debugging informations for ffmpegthumbnailer
RUN figlet ffmpegthumbnailer
RUN apt-get install -y ffmpegthumbnailer-dbg

#libffmpegthumbnailer-dev - development files for ffmpegthumbnailer
RUN figlet libffmpegthumbnailer
RUN apt-get install -y libffmpegthumbnailer-dev

#libffmpegthumbnailer4 - shared library for ffmpegthumbnailer
RUN figlet libffmpegthumbnailer4
RUN apt-get install -y libffmpegthumbnailer4

#ffmpegthumbs - video thumbnail generator using ffmpeg
RUN figlet ffmpegthumbs
RUN apt-get install -y ffmpegthumbs

#libffms2-3 - Cross platform ffmpeg wrapper library
RUN figlet libffms2
RUN apt-get install -y libffms2-3

#gmerlin-encoders-ffmpeg - ffmpeg encoders for Gmerlin
RUN figlet
RUN apt-get install -y gmerlin-encoders-ffmpeg

#libpostproc-dev - FFmpeg derived postprocessing library - development headers
RUN figlet libpostproc
RUN apt-get install -y libpostproc-dev

#libpostproc52 - FFmpeg derived postprocessing library
RUN figlet libpostproc52
RUN apt-get install -y libpostproc52

#moc-ffmpeg-plugin - ncurses based console audio player - ffmpeg plugin
RUN figlet moc-ffmpeg-plugin
RUN apt-get install -y moc-ffmpeg-plugin

#libtaoframework-ffmpeg-cil-dev - Tao CLI binding for FFmpeg - development files
RUN figlet libtaoframework
RUN apt-get install -y libtaoframework-ffmpeg-cil-dev

#libtaoframework-ffmpeg0.4-cil - Tao CLI binding for FFmpeg
RUN figlet libtaoframework
RUN apt-get install -y libtaoframework-ffmpeg0.4-cil

#winff - graphical video and audio batch converter using ffmpeg or avconv
RUN figlet winff
RUN apt-get install -y winff

#libxine2-ffmpeg - MPEG-related plugins for libxine2
RUN figlet libxine2
RUN apt-get install -y libxine2-ffmpeg

## ListInstalledPackages => https://wiki.debian.org/ListInstalledPackages
#RUN dpkg-query -l

## NOTE:
##need setup php variables date and maxupload file and others variables. ==> https://howto.biapy.com/en/debian-gnu-linux/servers/php/manage-php-ini-options-from-command-line-on-debian

##Install FFmpeg on Debian  => https://superuser.com/questions/286675/how-to-install-ffmpeg-on-debian
#https://www.johnvansickle.com/ffmpeg/
## System modules

#RUN apt-get install deb-multimedia-keyring
#RUN apt-get update
#RUN apt-get install -y ffmpeg

## ====================================================================== > End of ffmpeg stufs



## APACHE2  basic installation
RUN figlet APACHE2
RUN apachectl -M
RUN a2enmod rewrite
RUN a2enmod expires
RUN service apache2 restart
RUN apachectl -M


## ====================================================================== > PHP modules

## Note: when installing from php5 for some modules we need to copy from php5/mods-available to local/etc/php/conf.d and create a simbolic link
RUN figlet PHP_MODULES
RUN php -m

RUN apt-get install -y php5-common

RUN apt-get install -y php-calendar
#RUN cp /etc/php5/mods-available/calendar.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/calendar.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/calendar.so

#RUN docker-php-ext-install calendar 

RUN docker-php-ext-install bcmath

RUN apt-get install -y php5-mhash
#RUN cp /etc/php5/mods-available/mhash.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mhash.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mhash.so

RUN apt-get install -y php5-intl
RUN cp /etc/php5/mods-available/intl.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/intl.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/intl.so

RUN apt-get install -y php5-mcrypt
RUN cp /etc/php5/mods-available/mcrypt.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mcrypt.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mcrypt.so

RUN apt-get install -y php5-redis
RUN cp /etc/php5/mods-available/redis.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/redis.so

RUN apt-get install -y php5-mysql
RUN cp /etc/php5/mods-available/mysql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mysql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysql.so

RUN cp /etc/php5/mods-available/opcache.ini /usr/local/etc/php/conf.d

RUN apt-get install -y php5-gd
RUN cp /etc/php5/mods-available/gd.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/gd.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gd.so

RUN apt-get install -y php5-gdcm
RUN cp /etc/php5/mods-available/gdcm.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/gdcm.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gdcm.so

RUN apt-get install -y php5-vtkgdcm
RUN cp /etc/php5/mods-available/vtkgdcm.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/vtkgdcm.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/vtkgdcm.so

RUN apt-get install -y php5-ldap
RUN cp /etc/php5/mods-available/ldap.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/ldap.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/ldap.so

RUN apt-get install -y php5-xsl
RUN cp /etc/php5/mods-available/xsl.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/xsl.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xsl.so

RUN apt-get install -y php5-tidy
RUN cp /etc/php5/mods-available/tidy.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/tidy.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/tidy.so

RUN apt-get install -y php5-xmlrpc
RUN cp /etc/php5/mods-available/xmlrpc.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/xmlrpc.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xmlrpc.so

RUN apt-get install -y php5-pgsql
RUN cp /etc/php5/mods-available/pgsql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pgsql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pgsql.so


RUN cp /etc/php5/mods-available/mysqli.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/mysqli.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/mysqli.so
RUN cp /etc/php5/mods-available/pdo.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo.so
RUN cp /etc/php5/mods-available/pdo_mysql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo_mysql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo_mysql.so
RUN cp /etc/php5/mods-available/pdo_pgsql.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/pdo_pgsql.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo_pgsql.so
RUN cp /etc/php5/mods-available/readline.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/readline.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/readline.so

#RUN apt-get install -y php5-snmp
#RUN cp /etc/php5/mods-available/snmp.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/snmp.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/snmp.so

RUN figlet PHP_MODULES
RUN php -m

## PHP extra modules
#RUN apt-get install -y php-horde-date-parser  ##The command '/bin/sh -c apt-get install -y php-horde-date-parser' returned a non-zero code: 100
#RUN apt-get install -y php-horde-date
#RUN apt-get install -y php-horde-timezone
#RUN apt-get install -y php-horde-timeobjects
#RUN apt-get install -y php-timer



#RUN apt-get install -y php-horde-icalendar
#RUN apt-get install -y php-horde-kronolith
#RUN apt-get install -y php-doctrine-dbal
#RUN apt-get install -y phpldapadmin
#RUN apt-get install -y php-horde-ldap
#RUN apt-get install -y php-net-ldap
#RUN apt-get install -y php-net-ldap2
#RUN apt-get install -y php-mdb2-driver-pgsql
#RUN apt-get install -y libnusoap-php
#RUN apt-get install -y php-soap
#RUN apt-get install -y php-fxsl
#RUN apt-get install -y php-horde-text-filter-csstidy
#RUN apt-get install -y php-pclzip
#RUN apt-get install -y libphp-pclzip

#RUN apt-get update

#RUN cp /etc/php5/mods-available/json.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/json.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/json.so


#Manage PHP ini options from command line on Debian => https://howto.biapy.com/en/debian-gnu-linux/servers/php/manage-php-ini-options-from-command-line-on-debian
#RUN apt-get install -y php5-cli


### Note: Compare content

#PHP5
#cd /usr/local/etc/php/conf.d
#cd /etc/php5/mods-available/


#PHP 
#cd /usr/local/lib/php/extensions/no-debug-non-zts-20131226
#cd /usr/lib/php5/20131226/



## Note: when module is php5 need to make it available inside php/extensions (create a simbolic link)
#RUN cp /etc/php5/mods-available/MODULE.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/MODULE.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/MODULE.so


## ====================================================================== > End of PHP modules




## ====================================================================== > REDIS
RUN figlet REDIS
RUN apt-get install -y telnet redis-server
RUN apt-get install -y redis-server

## ====================================================================== > NPM
RUN figlet NPM
RUN apt-get install -y npm

## ====================================================================== > COPYING php.ini
RUN figlet COPYING__php.ini
RUN cp /etc/php5/cli/php.ini /usr/local/etc/php/
RUN ls -l /usr/local/etc/

## ====================================================================== > XDEBUG
# XDEBUG EXTENSION FOR PHP | DOCUMENTATION => https://xdebug.org/docs/remote 
#
# install xdebug and enable it. This block of code goes through the installion from source and compiling steps found
# on the xdebug website
# https://xdebug.org/docs/install
RUN figlet INSTALLING__XDEBUG
RUN cd /tmp \
    && wget http://xdebug.org/files/xdebug-2.5.4.tgz \
    && tar -xvzf xdebug-2.5.4.tgz \
    && cd xdebug-2.5.4 \
    && phpize \
    && ./configure  \
    && make \
    && cp modules/xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/

RUN figlet INSIDE_no-debug-non-zts-20131226/         
RUN ls -l /usr/local/lib/php/extensions/no-debug-non-zts-20131226/



#https://stackoverflow.com/questions/47596381/how-to-setup-an-variable-env-inside-dockerfile-to-be-overriden-in-a-docker-conta?noredirect=1#comment82150863_47596381
# ADD xdebug configurations
RUN figlet SETTING__XDEBUG__php.ini
RUN { \
        echo '[xdebug]'; \
        echo 'zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so'; \
        echo 'xdebug.remote_enable=1'; \
        echo 'xdebug.remote_port=9000'; \  
        echo 'xdebug.remote_autostart=1'; \
        echo 'xdebug.remote_handler=dbgp'; \
        echo 'xdebug.idekey=dockerdebug'; \
        echo 'xdebug.profiler_output_dir="/var/www/html"'; \
        echo 'xdebug.remote_connect_back=0'; \
        echo 'xdebug.remote_host=$REMOTE_HOST'; \
    } >> /usr/local/etc/php/php.ini



RUN figlet XDEGUB__IN__php.ini
RUN cat /usr/local/etc/php/php.ini


#With an unknown IP/multiple developers
#xdebug.remote_host
#Type: string, Default value: localhost
#Selects the host where the debug client is running, you can either use a host name, IP address, 
#or 'unix:///path/to/sock' for a Unix domain socket. 
#This setting is ignored if xdebug.remote_connect_back is enabled.

#https://stackoverflow.com/questions/4421633/who-is-listening-on-a-given-tcp-port-on-mac-os-x
#lsof -i :9001
#netstat -anv | grep 9001


#https://www.wikihow.com/Find-Your-IP-Address-on-a-Mac
#ifconfig | grep "inet " | grep -v 127.0.0.1
#   inet 10.20.1.210 netmask 0xfffffe00 broadcast 10.20.1.255

#https://apple.stackexchange.com/questions/20547/how-do-i-find-my-ip-address-from-the-command-line
#ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'

#https://serversforhackers.com/c/getting-xdebug-working

#Debug your PHP in Docker with Intellij/PHPStorm and Xdebug
#https://gist.github.com/chadrien/c90927ec2d160ffea9c4



#https://github.com/laradock/laradock/issues/102
#Pointing 9000 to php-fpm with xdebug enabled
#https://forums.docker.com/t/ip-address-for-xdebug/10460/22







## ====================================================================== > COMPOSER

RUN figlet Escape_SUDO
RUN exit

RUN figlet Install__COMPOSER
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
    && php composer-setup.php \
    && php -r "unlink('composer-setup.php');" \
    && mv composer.phar /usr/bin/composer

RUN composer


## ====================================================================== > PhpUnit

RUN figlet PhpUnit
RUN curl https://phar.phpunit.de/phpunit-5.6.0.phar -L -o phpunit.phar
RUN chmod +x phpunit.phar
RUN mv phpunit.phar /usr/local/bin/phpunit



RUN figlet COPYING_entrypoint.sh
COPY entrypoint.sh /usr/local/bin/
RUN figlet Permission_entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

ENTRYPOINT [ "entrypoint.sh" ]

# EXPOSE - PORTS
RUN figlet EXPOSE_PORTS
EXPOSE 80
#EXPOSE 6379
EXPOSE 9000
CMD ["apache2-foreground"]



## ====================================================================== > Extra notes

## Clean up Docker
#docker rm $(docker ps -a)
#docker rmi $(docker images)
#docker build -t my_img . 

## RUN REDIS 
#Open up another terminal
#docker  exec -it  xxxxxCOntainerId bash 
#root@bxxxxxCOntainerId:/var/www/html# redis-server

#If another terminal is needed to get acces to the container:
#Open up another terminal
#docker  exec -it  xxxxxCOntainerId bash 

## ============================         Export the desired image    
## Exit the container and commit in order to save the last state
#docker commit e4a01807684f my_new_name_img

## Check the created image my_new_name_img is there
#docker images
#REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
#my_new_name_img           latest              cc49bbaafd2d        15 seconds ago      771MB

## Tag the image // https://www.youtube.com/watch?v=svs-_9SAYz0
#docker tag my_new_name_img  my_account_docker_hub/my_new_name_img:v001   


## Login.
#docker login
#myusername
#mypassword

## Publish the image
#docker push my_account_docker_hub/my_new_name_img:v001

#Remove all images and all containers 
#docker rmi -f $(docker images -q)
#docker rm $(docker ps -a -q) 

#Using the image just created and stored in the cloud
##docker run -p 80:80  -v path_to_your_project_folder:/var/www/html -e REMOTE_HOST=192.67.10.0 my_account_docker_hub/my_new_name_img:v001 apache2-foreground
## ou
##docker run -p 80:80  -v path_to_your_project_folder:/var/www/html -e REMOTE_HOST=$REMOTE_HOST my_account_docker_hub/my_new_name_img:v001 apache2-foreground

#Note: REMOTE_HOST is your local IP. That value will be used inside xdebug.remote_host. 
#Esse valor é importante para permitir uma conexão entre o xdebug e o IDE, principalmente o Intellij ou o PHPstrom. 
#No primeiro exemplo a variável $REMOTE_HOST pode ser usada em um script BASH  
#REMOTE_HOST=`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'` 
#para carregar o container automaticamente sem necessidade de passar o IP

# Documentation
#    https://docs.docker.com/engine/reference/commandline/pull/#proxy-configuration
#    https://docs.docker.com/docker-hub/orgs/
#    https://docs.docker.com/engine/reference/commandline/commit/
#    https://docs.docker.com/get-started/part2/#run-the-app
#    http://jasani.org/2014/11/19/docker-now-supports-adding-host-mappings/
#    https://docs.docker.com/engine/reference/commandline/push/#parent-command
#    https://docs.docker.com/docker-cloud/orgs/#convert-a-user-to-an-organization
#    http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html#chap_07
#    https://medium.com/ihme-tech/using-xdebug-with-intellij-inside-a-docker-container-dc8cbd844dc5
#    https://www.npmjs.com/package/redis-commander
#    https://www.youtube.com/watch?v=kQ3H_jhyW2w
#    https://docs.docker.com/samples/library/redis/
#    https://docs.docker.com/engine/reference/run/#network-settings
#    https://docs.docker.com/engine/reference/run/
#    http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_04_02.html
#    https://stackoverflow.com/questions/6207573/how-to-append-output-to-the-end-of-text-file-in-shell-script-bash
#    http://www.linuxfromscratch.org/lfs/view/6.1/chapter07/hosts.html
#    http://www.linfo.org/cat.html
#    https://redislabs.com/blog/so-youre-looking-for-the-redis-gui/

#http://tarunlalwani.com/post/debugging-php-xdebug-docker/
#https://medium.com/ihme-tech/using-xdebug-with-intellij-inside-a-docker-container-dc8cbd844dc5
#https://stackoverflow.com/questions/47357783/xdebug-with-intellij-and-docker-is-not-working-how-to-solve-it?noredirect=1#comment81686964_47357783
#https://xdebug.org/docs/remote
#https://stackoverflow.com/questions/46263043/how-to-setup-docker-phpstorm-xdebug-on-ubuntu-16-04/46265103#46265103
#http://www.mysolutions.it/phpstorm-server-xdebug-configuration/    

# How could I ping my docker container from my host // https://stackoverflow.com/questions/39216830/how-could-i-ping-my-docker-container-from-my-host
# docker inspect 64ad351e115f give me "IPAddress": "172.17.0.2",
# How to get a Docker container's IP address from the host? docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 64ad351e115f 172.17.0.2

That’s the entrypoint.sh which will inject Ip dynamically into php.ini by going to Xdebug.remote_host :

#!/bin/bash
set -e

# Check if our environment variable has been passed.
if [ -z "${REMOTE_HOST}" ]
then
  echo "REMOTE_HOST has not been set."
  exit 1
else
  sed -i.bak "s/\$REMOTE_HOST/${REMOTE_HOST}/g" /usr/local/etc/php/php.ini
fi

exec "$@"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.