How to pass arguments within docker-compose?

前端 未结 3 1184
我在风中等你
我在风中等你 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:59

    This can now be done as of docker-compose v2+ as part of the build object;

    docker-compose.yml

    version: '2'
    services:
        my_image_name:
            build:
                context: . #current dir as build context
                args:
                    var1: 1
                    var2: c
    

    See the docker compose docs.

    In the above example "var1" and "var2" will be sent to the build environment.

    Note: any env variables (specified by using the environment block) which have the same name as args variable(s) will override that variable.

提交回复
热议问题