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:

  • How do I copy the files from one directory to another using a dockerfile?
  • Deployment with only SSH Key and dockerfile
  • Error in docker container bash: vi: command not found
  • Get Elasticache address from within a docker Elastic Beanstalk container
  • containerized nginx log rotation with logrotate
  • Docker php:5.6-Apache Development Environment missing permissions on volume mount
  • sudo docker build -t="hello" .

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

  • Docker tomcat7 container cannot connect to host activemq
  • Why did host network.service restart sever communications with all containers?
  • How to update a Kubernetes deployment on Google Container Engine?
  • Kubernetes PetSet - FailedCreate of persistent volume
  • Can't expose a fuse based volume to a Docker container
  • --add-host parameter in Marathon docker application
  • 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.