Building docker images from a source directory using different dockerfiles

前端 未结 1 985
盖世英雄少女心
盖世英雄少女心 2021-02-19 02:55

My goal is to build several different docker images , from the same source code.

i have my ./src folder (node.js project). inside ./src i have first.dockerfile and seco

1条回答
  •  星月不相逢
    2021-02-19 03:25

    Since Docker 1.5, you can use the -f argument to select the Dockerfile to use e.g:

    docker build -t doronaviugy/myproject -f dockerfiles/first.docker .

    If you use stdin to build your image ( the - < first.docker syntax), you won't have a build context so you will be unable to use COPY or ADD instructions that refer to local files.

    If you have to use an older version of Docker, you'll need to use some scripting to copy your specific Dockerfiles to Dockerfile at the root of the build context before calling docker build.

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