0

I have a Dockerfile, in which im trying to run a deamon that starts a java process.

If I embed the script in the Dockerfile, like so.

RUN myscript.sh

When I run /bin/bash on the resulting container, I see no entries from jps.

However, I can easily embed the script as CMD in which case, when i issue

docker run asdfg

I see the process start normally.

So, my question is, when we start a background async process in a Dockerfile, is it always the case that its side effects will be excluded from the container?

jayunit100
  • 17,388
  • 22
  • 92
  • 167

1 Answers1

2

Background-processes needs to be started at container-start, not image build. So your script needs to run via CMD or ENTRYPOINT.

CMD or ENTRYPOINT can still be a script, containing multiple commands. But I would imagine in your case, if you want several background processes, that using example supervisord would be your best option.

Also, check out some already existing Dockerfiles to get an idea of how it all fits together.

xeor
  • 5,301
  • 5
  • 36
  • 59