Docker Community Forums

Share and learn in the Docker community.

Docker image is malfunctioning

Hi

I have created a node back-end server. that has nearly 20 API services. Everything is working fine in local system. Problems starts when using docker image. I can able to create docker image successfully using below docker file setup.
FROM node:12-alpine
RUN apk update && apk add python make g++ && rm -rf /var/cache/apk/ *
RUN mkdir -p /home/FACE_RECOGNITION_SOFTWARE/backend/node_modules && chown -R node:node /home/FACE_RECOGNITION_SOFTWARE/backend
WORKDIR /home/FACE_RECOGNITION_SOFTWARE/backend
COPY package .json ./ *
USER node
RUN npm install --only=production
COPY --chown=node:node . .
EXPOSE 1337
ENTRYPOINT [ “node”, “server.js”]

Docker image is running in container as usual. but when i am making api requests from postman, only specific APIs are giving proper response but remaining APIs are giving empty response. I have tried running docker image in both local system and aws ec2 instance. same issue is coming. But without using docker image, all the APIs are giving proper response when i am running it locally without docker image.

Kindly help me out to sort out this issue.

I encountered a similar problem, which can be fixed in the following ways:

Method 1: based on docker cp, copy the file contents of the damaged container to the current environment (even if the container cannot be started);
Method 2: based on docker commit resubmit the damaged container as another image, and then start the additional entry point entry;
Note: the above methods are just a few tricks to use during debugging or development, and eventually we should write the related operations into the Dockerfile configuration or docker-compose.yml configuration.

Fix Progress:

Because I temporarily modified the ./php-fpm.d/www.conf configuration in my PHP-FPM container, the container could not be started:
$ docker-compose ps
Name Command State Ports

phpfpm_fpm_1 docker-php-entrypoint php-fpm Restarting
phpfpm_nginx_1 nginx -g daemon off; Up 80/tcp, 0.0.0.0:86->86/tcp
Check related error information by docker-compose log-f:
fpm_1 | [03-Dec-2019 03:57:50] ERROR: Unable to create or open slowlog(/usr/local/log/www.log.slow): No such file or directory (2)
fpm_1 | [03-Dec-2019 03:57:50] ERROR: Unable to create or open slowlog(/usr/local/log/www.log.slow): No such file or directory (2)
fpm_1 | [03-Dec-2019 03:57:50] ERROR: failed to post process the configuration
fpm_1 | [03-Dec-2019 03:57:50] ERROR: failed to post process the configuration
fpm_1 | [03-Dec-2019 03:57:50] ERROR: FPM initialization failed
fpm_1 | [03-Dec-2019 03:57:50] ERROR: FPM initialization failed
fpm_1 | [03-Dec-2019 03:58:51] ERROR: Unable to create or open slowlog(/usr/local/log/www.log.slow): No such file or directory (2)
fpm_1 | [03-Dec-2019 03:58:51] ERROR: Unable to create or open slowlog(/usr/local/log/www.log.slow): No such file or directory (2)
fpm_1 | [03-Dec-2019 03:58:51] ERROR: failed to post process the configuration
fpm_1 | [03-Dec-2019 03:58:51] ERROR: failed to post process the configuration
fpm_1 | [03-Dec-2019 03:58:51] ERROR: FPM initialization failed
fpm_1 | [03-Dec-2019 03:58:51] ERROR: FPM initialization failed
Check the configuration information manually debugged in the container by docker diff container-id:
docker ps -a|grep php 5dfe26f00059 tkstorm/phpngx "nginx -g 'daemon of…" 2 weeks ago Up 41 hours 80/tcp, 0.0.0.0:86->86/tcp phpfpm_nginx_1 6f8a2044ba36 tkstorm/phpfpm "docker-php-entrypoi…" 2 weeks ago Restarting (78) 7 seconds ago phpfpm_fpm_1 Copy the wrong ./php-fpm.d/www.conf configuration that damaged the container to the local directory and fix it: docker cp phpfpm_fpm_1:/usr/local/etc/php-fpm.d/www.conf fix-www.conf

$ vi fix-www.conf

slowlog = /var/log/pool.log.slow ... Copy the repaired configuration to the damaged container again: // after fix up docker cp fix-www.conf phpfpm_fpm_1:/usr/local/etc/php-fpm.d/www.conf
Restart the container:
$ docker restart phpfpm_fpm_1

// it’ fix ok
$ docker-compose ps
Name Command State Ports

phpfpm_fpm_1 docker-php-entrypoint php-fpm Up 9000/tcp
phpfpm_nginx_1 nginx -g daemon off; Up 80/tcp, 0.0.0.0:86->86/tcp