I have a nginx and php-fpm containers. When I'am in my php container in a projet and I exec any command (like vendor/bin/behat or composer update) who takes time and I click on CTRL+C. I'm ejected from the container. I don't know why.. When I click on CTRL+C without executing commands i don't have the problem.
Any idea ?
This is my docker-compose.yml file :
version: '3' services: nginx: image: nginx:latest restart: always ports: - "80:80" volumes: - ./nginx/conf:/etc/nginx/custom_conf - ./nginx/hosts:/etc/nginx/conf.d/ - ./nginx/nginx.conf:/etc/nginx/nginx.conf - ./logs/nginx:/var/log/nginx - ..:/var/www networks: my_network: ipv4_address: 10.5.0.31 web: build: . restart: always ports: - "9000:9000" - "5001:5001" volumes: - ./php/php.ini:/usr/local/etc/php/conf.d/30-php.ini - ./php/app2.conf:/usr/local/etc/php/conf.d/app2.conf - ./keys/:/var/www/.ssh - ./custom-hosts:/etc/custom-hosts - ..:/var/www - ./supervisor/supervisord.conf:/etc/supervisor/supervisord.conf - ./supervisor/conf/:/etc/supervisor/conf.d/ networks: my_network: ipv4_address: 10.5.0.20 tty: true db: build: mysql restart: always ports: - "3306:3306" volumes: - ./logs/mysql:/var/log/mysqld.log - ./mysql/sql:/var/dumps - data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_USER=root - MYSQL_PASSWORD=root networks: my_network: ipv4_address: 10.5.0.23 volumes: data: driver: local networks: my_network: driver: bridge ipam: config: - subnet: 10.5.0.0/16
My php-fpm Dockerfile:
FROM php:7.1-fpm WORKDIR /var/www RUN apt-get update && apt-get install -y wget git vim sudo unzip apt-utils RUN apt-get install -y gnupg RUN apt-get update ### composer RUN cd /usr/src RUN curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer # xdebug RUN pecl install xdebug-2.5.0 \ && docker-php-ext-enable xdebug ### php extension RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections RUN apt-get clean && apt-get update && apt-get -y --fix-missing install libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng-dev \ libicu-dev \ libxml2-dev \ g++ \ zlib1g-dev RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ RUN docker-php-ext-install -j$(nproc) gd RUN docker-php-ext-install exif RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-configure intl RUN docker-php-ext-install intl RUN apt-get install -y libzip-dev RUN docker-php-ext-install zip ### main RUN usermod -u 1000 www-data RUN chmod -R 777 /var/www/ RUN chown -R www-data:www-data /var/www ADD bash_profile /var/www/.bash_profile ADD script.sh /usr/bin/script.sh RUN chmod 755 /usr/bin/script.sh CMD ["bin/bash"] ENTRYPOINT ["script.sh"] EXPOSE 9000
And my script.sh :
#! /bin/bash php-fpm & echo "Serveur de développement Cartesia Education" cat /etc/custom-hosts >> /etc/hosts dpkg-reconfigure -f noninteractive tzdata echo "LC_TIME=fr_FR.utf8" >> /etc/environment service supervisor start exec su -l www-data -s /bin/bash
Thank you for your help.
Have you tried running the container in detached mode (-d option)?
> docker run -d [CONTAINER-NAME]
This will cause the container to run in the background. You can still SSH into the running container by:
> docker exec -it [CONTAINER-NAME] bash
Exiting the container once in will not terminate it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With