Reputation: 2944
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 second dockerfile.
for building the the project i use this standard command line
sudo docker build -t doronaviugy/myproject .
This works with no problems using the default Dockerfile
I'm trying to build it from a specific dockerfile using the line
sudo docker build -t doronaviguy/myproject - < first.docker
this line works, but now path doesn't being copy inside the image
#Inside the Dockerfile
ADD . /src
I think i understand how to specify a dockerfile argument, but i need to specify a direcotry argument to be copied inside the docker image.
Thanks a lot.
Upvotes: 35
Views: 69692
Reputation: 46480
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
.
Upvotes: 69