This project contains a simple and practical example of a Dockerfile to help beginners learn how to use Docker.
- Docker installed on your system
- Basic knowledge of the Linux command line
-
FROM ruby:2.7-alpine
: Use the official Ruby 2.7 image as our base image. We're using the Alpine version to keep the image small. -
WORKDIR /app
: Set the working directory in the container to /app. -
COPY Gemfile Gemfile.lock ./
: Copy the Gemfile and Gemfile.lock files from the current directory to the container. -
RUN bundle install
: Install the project dependencies using Bundler. -
COPY . .
: Copy the rest of the application code to the container. -
CMD ["ruby", "app.rb"]
: Set the command to start the application.
- Clone the repository:
git clone https://github.com/devopshobbies/docker-templates.git
- Build the Docker image:
cd docker-templates
docker build -t hello-ruby .
- Run the Docker container:
docker run -it --rm hello-ruby