I have this folder structure
folder_ext folder_docker |---> folder_int folder_1 folder_2 .......
My docker files are all included inside the folder_docker. Inside my docker-compose.yml file, I set the context like this
version: '3' services: nginx: container_name: my_nginx build: context: .. dockerfile: ./folder_docker/nginx/Dockerfile
Dockerfile I copy some files from folder_ext
COPY ./folder_ext /container_folder_ext
but somewhere below I copy also files from
COPY ./folder_docker/nginx/nginx.tmpl /etc/nginx/conf.d/nginx.tmpl
I am using also
.dockeringore to ignore folders & files that I am not using.
Unfortunately, this takes too long under WSL2 (Ubuntu distro) to begin the building process about ~25 minutes before it starts to process the 1st command inside the Dockerfile. I don’t know why, but that’s is a huge problem for me since I want to make many builds and I am losing my time with this stall.
If I use an alternative scenario like this below, where context is set inside the
the build begins almost instantly (~2 seconds) BUT I get an error "docker forbidden path outside the build context" for the 2nd COPY
COPY ../folder_docker/nginx/nginx.tmpl /etc/nginx/conf.d/nginx.tmpl
I don’t want to move my folder infrastructure just to make it build faster because it’s a git project that follows this folder structure. This seems to be a WSL2/Windows problem since under the production server the building times are acceptable.
Any other solution?
Source: Docker Questions