Run a service automatically in a docker container

前端 未结 6 543
予麋鹿
予麋鹿 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:03

    The explanation for:

    If I run it using docker run -i -t quintenk/riak-dev /bin/bash the riak process is not started

    is as follows. Using CMD in the Dockerfile is actually the same functionality as starting the container using docker run {image} {command}. As Gigablah remarked only the last CMD is used, so the one written in the Dockerfile is overwritten in this case.

    By using CMD /bin/riak start && tail -f /var/log/riak/erlang.log.1 in the Buildfile, you can start the container as a background process using docker run -d {image}, which works like a charm.

提交回复
热议问题