Docker Community Forums

Share and learn in the Docker community.

Pass variable to dockerfile from the other file (not in docker-compose.yml or via docker-compose.yml)

build

(Dyel0216) #1

I want to pass the variable used in the dockerfile from an external file.
Is it possible to get the args variable from an external file like env_file?

// docker-compose up -d

version: '3'
services:
  app:
    build:
      image: python3.6.6-stretch-slim
      context: .
      dockerfile: ./Dockerfile
      args:
        NGINX_VERSION: 1.15.3-1~stretch
        NJS_VERSION: 1.15.3.0.2.3-1~stretch
    container_name: app
    volumes:
      - ../:/app
    ports:
      - "8080:80"
    restart: always