How to pass environment variable to docker-compose up

后端 未结 3 1937
我寻月下人不归
我寻月下人不归 2020-12-03 06:11

I am trying to run a container. I already have the image uploaded to private Docker registry. I want to write a compose file to download and deploy the image. But I want to

3条回答
  •  猫巷女王i
    2020-12-03 07:14

    In your docker-compose.yml file add

    env_file:
      - .env_file
    

    to your db service where .env_file is your .env file (change its name accordingly).

    version: '3'
    services:
       db:
        #build: k-db
        user: "1000:50"
        volumes:
          - /data/mysql:/var/lib/mysql
        container_name: k-db
        env_file:
          - .env_file
        environment:
          - MYSQL_ALLOW_EMPTY_PASSWORD=yes
        image:  XX:$KB_DB_TAG_VERSION
        image: k-db
        ports:
          - "3307:3306"
    

提交回复
热议问题