Run a service automatically in a docker container

前端 未结 6 525
予麋鹿
予麋鹿 2020-12-04 09:10

I\'m setting up a simple image: one that holds Riak (a NoSQL database). The image starts the Riak service with riak start as a CMD. Now, if I run it as a daemon

6条回答
  •  天命终不由人
    2020-12-04 10:13

    To keep docker containers running, you need to keep a process active in the foreground.

    So you could probably replace that last line in your Dockerfile with

    CMD /bin/riak console
    

    Or even

    CMD /bin/riak start && tail -F /var/log/riak/erlang.log.1
    

    Note that you can't have multiple lines of CMD statements, only the last one gets run.

提交回复
热议问题