Running a Rails Server with Our Image
Explore how to start a Rails server inside a Docker container built from a custom image. Understand the need to bind the server to all IP addresses, use the port publishing option to expose the app externally, and find the container's IP address for network access. This lesson guides you through running and configuring your Rails app within Docker.
Run Rails Server
Now that we have created our own tailor-made image, we should be able to start up a Rails server to run our app. Let’s try doing that now. We can start our Rails app inside a container based on our custom image with the following command:
$ docker run -p 3000:3000 railsapp bin/rails s -b 0.0.0.0
This docker run command says, “Start a container based on our custom image railsapp, and run bin/rails s -b 0.0.0.0 inside it.” The -b option is needed in binding the Rails server to IP addresses.
Let’s run it now by clicking the Run button. You should see the familiar Rails welcome page in the ...