partydrone PRO said over 2 years ago on Docker on Rails 7 :
Another suggestion I would make is to decouple the Linux flavor from the Ruby version passed into the build context. For example, in your Dockerfile, FROM should read:

ARG RUBY_VERSION
FROM ruby:${RUBY_VERSION}-alpine
# …

Then in your docker-compose.yml file, pass only the Ruby version:

service:
  web:
    build:
      args:
        RUBY_VERSION: 2.6.8

The reason for doing this is the Dockerfile uses Alpine-specific commands for installing packages (apk instead of apt). If someone passes in "2.6.8-buster" then they've broken the Dockerfile and the build will fail.