Score:0

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

gb flag

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

enter image description here

enter image description here

in flag
Please don't post screenshots of text when you can just copy and paste the text instead.
Score:1
hr flag

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.

Serji avatar
gb flag
Thanks, I have tried as you told but when ever am giving CMD as starting fluentd agent it is exiting the container. ``` CMD ["/etc/init.d/td-agent", "start" ] ENTRYPOINT []
hr flag
Updated the answer to include running multiple processes. Looking at your specific use-case, you should probably not add fluentd to the existing container image. I would recommend to look into running fluentbit/fluentd as a sidecar container.
Serji avatar
gb flag
Thanks, I will try on that. will update
Serji avatar
gb flag
Hi , I have changed the application log from the customized path to /dev/stdout and it's resolved the issue.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.