简体   繁体   中英

how to run a process on startup without CMD or ENTRYPOINT in a dockerfile?

Here's some example dockerfile:

FROM ubuntu:18.04
RUN apt-get install xvfb

CMD Xvfb :0 -ac # <-- I need this to run on start up, no as CMD

CMD node programThatNeedsXvfbRunning.js

I need Xvfb :0 -ac to be running inside the image by default, so that I can do docker run my-container someCustomCmdThatRequiresXvfbrunning

I know I could do Xvfb :0 -ac & node myapp but that seems stupid to have to do this every time.

Try this Dockerfile :

FROM ubuntu:18.04
RUN apt-get install xvfb

ENTRYPOINT [ "Xvfb", ":0", "-ac" ]

Then run it as:

docker run <image> cmd1 cmd2

This should behave as if you ran:

Xvfb :0 -ac cmd1 cmd2

Is this what you want?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM