Running a Rails Server with Our Image
Learn to start up a Rails server to run the app.
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 Output Tab. You can also view it if you click on the URL in front of “Your app can be found at:”.
Get hands-on with 1400+ tech skills courses.