February 2019
Intermediate to advanced
240 pages
5h 25m
English
Currently, every time we want to start a Rails server in a container, we have to explicitly specify the command bin/rails s -b 0.0.0.0 as part of our docker run command:
| | $ docker run -p 3000:3000 railsapp \ |
| | bin/rails s -b 0.0.0.0 |
This is a shame because the main purpose of our custom image is to start a Rails server. It would be better if we could embed the knowledge of how to start the Rails server in the image itself.
We can do this by adding a new instruction to our Dockerfile. The CMD instruction, pronounced “command,” specifies the default command to run when a container is started from the image. Let’s use this in our Dockerfile to start the Rails server by default:
| | FROM ... |
Read now
Unlock full access