nickjj / docker-django-example

A production ready example Django app that's using Docker and Docker Compose.
MIT License
1.17k stars 249 forks source link

ERROR: Service 'css' failed to build : COPY failed: forbidden path outside the build context: #11

Closed cjonesyyc closed 2 years ago

cjonesyyc commented 2 years ago

Hi,

Great project, should save a lot of time! I'm trying to run on Ubuntu 20.04.3 LTS and I get the following error:

Step 10/12 : COPY --chown=node:node ../ ../
ERROR: Service 'css' failed to build : COPY failed: forbidden path outside the build context: ../ ()

Commenting out line 23 of the Dockerfile allows the build to finish

COPY --chown=node:node ../ ../

Perhaps I'm doing something wrong. Django starts up and everything looks good but I'm unsure the impact. Using WSL2 on Windows with the same OS works OK.

Thanks!

nickjj commented 2 years ago

Hi,

Are you using Docker Desktop or did you install Docker straight up within your Ubuntu WSL 2 instance?

That error usually happens when Docker's buildkit isn't enabled but Docker Desktop should enable it by default. It's been available from Docker for years but I don't think it's enabled by default with native Linux.

If you run DOCKER_BUILDKIT=1 docker-compose build does that fix it?

If so and you're not using Docker Desktop you can goto /etc/docker/daemon.json and add { "features": { "buildkit": true } } then restart the Docker daemon. That'll always enable buildkit without needing to supply the env variable.

cjonesyyc commented 2 years ago

Hi,

In Windows where it was working it was with Docker Desktop.

On the Ubuntu 20.04 VM I tried setting the env variable and it didn't work, seems like buildkit was missing in the install. I re-created the VM and install docker/docker-compose following official docker instructions and now that env variable works.

Thank you!

nickjj commented 2 years ago

No problem.

Did you enable it in the json config to avoid needing to set the env var every time?

cjonesyyc commented 2 years ago

Just tried that now, the file didn't exist on my machine so I created it and put the mentioned line and it's working without setting it every time. Much appreciated, thanks for the support and great project.