Quantcast
Viewing latest article 6
Browse Latest Browse All 23

Answer by Seyed Mostafa SeyedAshoor for How to include files outside of Docker's build context?

I was personally confused by some answers, so decided to explain it simply.

You should pass the context, you have specified in Dockerfile, to docker whenwant to create image.

I always select root of project as the context in Dockerfile.

so for example if you use COPY command like COPY . .

first dot(.) is the context and second dot(.) is container working directory

Assuming the context is project root, dot(.) , and code structure is like this

sample-project/  docker/    Dockerfile

If you want to build image

and your path (the path you run the docker build command) is /full-path/sample-project/,you should do this

docker build -f docker/Dockerfile . 

and if your path is /full-path/sample-project/docker/,you should do this

docker build -f Dockerfile ../ 

Viewing latest article 6
Browse Latest Browse All 23

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>