Pass a variable to a Dockerfile from a docker-compose.yml file

Basically I missed declaring the arg in the Dockerfile.

# docker-compose.yml file

version: '2'

services:
  django:
    build:
      context: .
      dockerfile: ./docker/Dockerfile
      args:
        - SOMETHING=foo

 

# Dockerfile
ARG SOMETHING
RUN echo $SOMETHING

Shoutout to @Lauri for showing me the light.

Leave a Comment