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

EXPOSE 3000

And this command:

  • Kitematic - Force using Virtualbox
  • Access host webcam using cvlc in Docker
  • Can you have a Docker registry with credentials?
  • Deploying an Angular app using Docker/Dokku
  • DC/OS JMX Access to java application
  • Docker doesn't RUN command as USER
  • sudo docker build -t="hello" .
    

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

  • Allowing custom scp/sftp/rsync in sandbox shell
  • Fixed issue with connecting to docker but don't know why the fix worked
  • Docker configuration using the systemd configuration style
  • Visual C++ for Linux Development + Docker
  • Kubernetes Pod Creation Speed
  • Failed to execute fabric8 docker plugin
  • 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.