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.
The basic syntax used to build an image using a Dockerfile is: docker build [OPTIONS] PATH | URL | - To build a docker image, you would therefore use: docker build [location of your dockerfile]
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. Thanks , i did to try to use the -f argument , but with no success, and then i noticed i had to upgrade my docker version to 1.5 .
This pipeline checks out the source code of the repository and then builds a dockerfile found at the subfolder docker while still keeping as Docker context the root directory. You could also change the Docker build context by editing the working_directory property.
You can check the content of the file by using the cat command: If you are already in the directory where the Dockerfile is located, put a . instead of the location: docker build . By adding the -t flag, you can tag the new image with a name which will help you when dealing with multiple images: docker build -t my_first_image .
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With