Docker-compose: Set a variable in env file and use it in Dockerfile

后端 未结 1 671
庸人自扰
庸人自扰 2021-01-18 10:08

I\'m using Docker and Docker-compose to build a stack of nginx+php.

I\'m trying to set the timezone in my .env file and use it in a Dockerfile, but I mi

相关标签:
1条回答
  • 2021-01-18 10:44

    You need to pass the build argument in docker compose

    version '2'
    
    services:
        php:
            build: 
              dockerfile: php7-fpm
              args:
                TIMEZONE: ${TIMEZONE}
            volumes:
                - ${APP_PATH}:/var/www/app
                - ./logs:/var/www/logs
    

    The environment are passed to the running container and not to the buildfile. For the you need to pass args in the build section

    0 讨论(0)
提交回复
热议问题