1

My docker-compose file looks like this:

version: '3.3'
services:
  app:
    container_name: my_script
    image: my_script
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - http_proxy=$HTTP_PROXY
        - https_proxy=$HTTPS_PROXY
        - environment
    volumes:
      - /home/me/PycharmProjects/myimportscript/logs:/app/logs
    command: >
      bash -c "python3 Main.py -env ***$environment***"

How can I use the environment arg in the command?

bash -c "python3 Main.py -env $environment"

Serge Zoghbi
  • 13
  • 1
  • 2

1 Answers1

2

You need to use double $, for example "$$MY_ENV".

More details here, if you want to use default values, etc.

https://docs.docker.com/compose/environment-variables/#substitute-environment-variables-in-compose-files

Hik
  • 101
  • 2