xxxxxxxxxx
#Option 1
#Add
stdin_open: true
#and
tty: true
#to each service you want to start up and remain running.
#Option 2
(While Running Multiple Containers or Single React Container)
Add "CI=true" as a command that should be executed before "npm install" in your Dockerfile within your React project root directory
FROM node:14.5
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN CI=true //NOTE
RUN npm install
COPY . /usr/src/app
EXPOSE 3000
CMD ["npm","start"]
#Option 3
(While Running Multiple Containers)
Setting "stdin_open:true" to your react instance
react:
stdin_open: true //NOTE:
build: dockerreact
ports: - "3000:3000"
xxxxxxxxxx
######## docker-compose.yml ########
services:
php:
restart: always
container_name: app-php
working_dir: /var/www/html
build:
context: ./docker/php
dockerfile: Dockerfile
ports:
- "9000:9000"
volumes:
- ./:/var/www/html
command: ["/bin/sh", "-c", "/startup/bootstrap.sh"]
networks:
default:
ipv4_address: 172.20.0.10
######## docker/php/DockerFile ########
FROM php:8.1.6-fpm-alpine3.14
COPY bootstrap.sh /startup/
RUN apk update \
&& apk add --no-cache \
bash \
libzip-dev \
zip \
unzip \
icu-dev \
&& docker-php-ext-configure \
intl \
&& docker-php-ext-install \
intl \
opcache \
mysqli \
pdo \
pdo_mysql \
&& docker-php-ext-enable \
pdo_mysql \
&& chmod -R 777 /startup/bootstrap.sh
######## /startup/bootstrap.sh ########
#!/bin/sh
echo "test ok"
php-fpm -F -R #fix exited with code 0
xxxxxxxxxx
-Exit code 0 indicates that the specific container does not have a foreground process attached.
-This exit code is the exception to all the other exit codes to follow. It does not necessarily mean something bad happened.
-Developers use this exit code if they want to automatically stop their container once it has completed its job.