Kamal's Dockerfile expectations

Kamal is in an essence a simple Docker wrapper. It provision your servers with Docker, builts your application image out of a provided Dockerfile and starts the application containers on them.

Kamal is language and framework agnostic, so there are only general expectations on the Docker image.

Running a web server

The most important part of your Dockerfile is how you'll run your application process with CMD directive.

By default, Kamal expects a running application on port 3000:

# Dockerfile
...
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]

EXPOSE tells Docker to expose the specified port and with CMD we run our application process. This will depend on your application server or framework.

In Rails, we either run ./bin/rails server, bundle exec rails server or directly bundle exec puma. If you come from a different programming background you might need to pass the port 3000 explicitely.

Starting the application on this port will make sure Kamal can successfuly route the incoming requests to this container.