I have the following docker-compose file
version: \'3\' services: node1: build: node1 image: node1 container_name: n
In your dockerfile:
ARG CERTBOT_TAG=latest FROM certbot/certbot:${CERTBOT_TAG}
In your docker-compose.yml:
version: '3' services: certbot-dns-namecheap: build: context: . args: - CERTBOT_TAG=v0.40.1
And you can use @lvthillo solution with '--build-arg'