Unable to start the container from docker image/ Its failing if we add CMD to start filebeat or fluentd agent

Unable to start the container from docker image/ Its failing if we add CMD to start filebeat or fluentd agent

am unable to start the container from the docker image that builds from below Dockerfile It's failing if we add CMD to start filebeat or fluentd agent.

Dockerfile

#################################################
FROM node:12
#install pm2
RUN npm install pm2 -g
RUN apt update
#create dir and copy the code
RUN mkdir -p /home/devops/comera_registration_service/
WORKDIR  /home/devops/comera_registration_service/
COPY . .
#fluentd install
COPY fl.sh . 
RUN sh fl.sh
#install depend
RUN npm install
#start the app
CMD [ "pm2-runtime", "ecosystem.config.js" ]
CMD ["/etc/init.d/td-agent", "start" ]  
#opening port
EXPOSE 3010

введите описание изображения здесь

введите описание изображения здесь

решение1

The node:12 image has an entrypoint script. When an ENTRYPOINT is specified, Docker will use the values in CMD as parameters for this entrypoint command.

The parent image entrypoint can be disabled by adding the following to your Dockerfile:

ENTRYPOINT []

As a side note, when multiple CMD instructions are specified in a Dockerfile, only the last one will be set in the resulting image.

With the Dockerfile above and the parent entrypoint removed, /etc/init.d/td-agent will be PID 1 of the container. Since this is an init script, it will exit when it's done starting the daemon. When PID 1 is gone, the container will exit.

To run multiple programs inside a container, a wrapper script or process manager is needed. Note that this is generally not recommended. Eg. on Kubernetes the sidecar container pattern is preferred.

Связанный контент