Commands to execute background process in Docker CMD

后端 未结 1 571
清酒与你
清酒与你 2021-02-02 07:12

I am creating a docker image using a Dockerfile. I would like to execute some scripts while starting the docker container. Currently I have a shell script to execute all the nec

1条回答
  •  眼角桃花
    2021-02-02 07:49

    Besides the comments on your question that already pointed out a few things about Docker best practices you could anyway start a background process from within your start.sh script and keep that start.sh script itself in foreground using the nohup command and the ampersand (&). I did not try it with mongod but something like the following in your start.sh script could work:

    #!/bin/sh
    ...
    nohup sh -c mongod --dbpath /test &
    ...
    

    0 讨论(0)
提交回复
热议问题