Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to specify the base image for a Rails app Dockerfile.
Ruby on Rails
FROM [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a Node or Python image instead of Ruby.
Using a generic OS image without Ruby installed.
✗ Incorrect
The base image for a Rails app typically uses a Ruby image, such as ruby:3.2.
2fill in blank
mediumComplete the code to copy the Gemfile into the Docker image.
Ruby on Rails
COPY [1] /usr/src/app/Gemfile Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Copying the wrong directory or file.
Copying the Dockerfile instead of Gemfile.
✗ Incorrect
The Gemfile must be copied to the image to install gems.
3fill in blank
hardFix the error in the command to install gems in the Dockerfile.
Ruby on Rails
RUN bundle [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
bundle update which updates gems but does not install missing ones.Using
bundle remove which removes gems.✗ Incorrect
The correct command to install gems is bundle install.
4fill in blank
hardFill both blanks to expose the correct port and set the working directory.
Ruby on Rails
EXPOSE [1] WORKDIR [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Exposing port 8080 which is not default for Rails.
Setting working directory to a non-standard path.
✗ Incorrect
Rails apps usually run on port 3000, and the working directory is often set to /usr/src/app inside the container.
5fill in blank
hardFill all three blanks to run the Rails server with the correct command and environment.
Ruby on Rails
CMD ["rails", "[1]", "-b", "0.0.0.0", "-e", "[2]", "-p", "[3]"]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'console' instead of 'server' to start Rails.
Setting environment to 'development' instead of 'production'.
Using wrong port number.
✗ Incorrect
The command runs the Rails server in production mode on port 3000, binding to all interfaces.