This repository contains Dockerfile of Ruby runtime for Docker's automated build published to the public Docker Hub Registry.
This image is a base image that makes it easy to dockerize standard Rack application.
It can automatically bundle a Rack application and its dependencies with a single line Dockerfile.
This project heavily borrowed code from Google's google/ruby-runtime Docker image.
-
Install Docker.
-
Download automated build from public Docker Hub Registry:
docker pull dockerfile/ruby-runtime(alternatively, you can build an image from Dockerfile:
docker build -t="dockerfile/ruby-runtime" github.com/dockerfile/ruby-runtime)
This image assumes that your application:
- has a
Gemfileand its correspondingGemfile.lockfor bundler, and theGemfilecontains Rack. - has
config.rufor Rack. - listens on port
8080.
When building your application docker image, ONBUILD triggers
- Installs gems specified in the
Gemfileand leverage docker caching appropriately. - Copy the application sources under the
/appdirectory in the container.
The image uses WEBrick as the application server by default. You can overwrite it by adding mongrel/thin/puma to Gemfile and configuring in your Dockerfile like:
ENV APPSERVER puma
Or you can just overwrite CMD in your Dockerfile like:
CMD ["bundle", "exec", "unicorn", "-c", "unicorn.conf", "config.ru"]
- Step 1: Create a Dockerfile in your
Rackapplication directory with the following content:
FROM dockerfile/ruby-runtime- Step 2: Build your container image by running the following command in your application directory:
docker build -t="app" .- Step 3: Run application by mapping port
8080:
APP=$(docker run -d -p 8080 app)
PORT=$(docker port $APP 8080 | awk -F: '{print $2}')
echo "Open http://localhost:$PORT/"