How to run a docker container as a daemon starting the rails project built inside?

I’ve built an image with this Dockerfile:

FROM rails

RUN apt-get update
RUN mkdir /home/projects
WORKDIR /home/projects

RUN rails new hello


And this command:

  • Saltstack docker.login returns APIError: 500 Server Error?
  • How to run redmine with a postgresql database using docker compose
  • docker info registry showing v1 and in docker run getting v2
  • Docker-compose does not install or run properly on boot2docker
  • how to make ebs volume usable by docker stack
  • SSH directly into a docker container
  • sudo docker build -t="hello" .

    Now my question is how to get the container running as a daemon and with the rails server command ?

  • How can I run Lektor within a Docker container?
  • Easy way to give docker container access to my local domains (.local, .dev)
  • Running Client program and API in same Docker Machine
  • Why is apt-get update failing inside of a docker container?
  • with Docker
  • Install node in Dockerfile?
  • One Solution collect form web for “How to run a docker container as a daemon starting the rails project built inside?”

    To use a default command with a Dockerfile, you can use CMD:

    CMD /bin/rails server

    This will run bash -c /bin/rails server. You can also do

    CMD ["/bin/rails", "server"] which avoids the bash parent process.

    (I’m not familiar with rails, but you get the idea.)

    You can also use ENTRYPOINT instead of CMD which has various differences from CMD, such as how you can pass arguments to the main command.

    docker run -d hello will run the container as a daemon.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.