How to pass arguments within docker-compose?

前端 未结 3 1157
我在风中等你
我在风中等你 2020-11-30 01:23

Docker 1.9 allows to pass arguments to a dockerfile. See link: https://docs.docker.com/engine/reference/builder/#arg

How can I pass the same arguments within dock

3条回答
  •  有刺的猬
    2020-11-30 01:58

    Now docker-compose supports variable substitution.

    Compose uses the variable values from the shell environment in which docker-compose is run. For example, suppose the shell contains POSTGRES_VERSION=9.3 and you supply this configuration in your docker-compose.yml file:

    db:
      image: "postgres:${POSTGRES_VERSION}"
    

    When you run docker-compose up with this configuration, Compose looks for the POSTGRES_VERSION environment variable in the shell and substitutes its value in. For this example, Compose resolves the image to postgres:9.3 before running the configuration.

提交回复
热议问题