question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django container complains "error walking file system" when venv is installed

See original GitHub issue

What happened?

After creating a fresh project, and then docker-compose build and up, The Django Docker container infinitely complains “error walking file system”.

What should’ve happened instead?

The Django container should start without any errors.

Additional details

This happens if you have a Python venv environment installed anywhere inside the project directory. The problem is, inside the docker container, venv symlinks to files that don’t exist in the container (e.g. /usr/bin/python3.8). I have a venv to test changes to requirements locally instead of waiting for a docker-compose build to fail (which takes a lot longer).

Steps to reproduce

Inside a new or existing cookiecutter project directory

docker-compose -f local.yml build
docker-compose -f local.yml up

Stop the containers (ctrl-c). Now, create a new python venv

python -m venv venv

Now bring up your containers and the Django Container will constantly complain “error walking file system”:

docker-compose -f local.yml up

I assume this is watchgod complaining. Let me know if this is correct or not.

If you’re open to a fix for this issue, I’ll open a pull request to update the Dockerfile and fix this problem.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:19

github_iconTop GitHub Comments

5reactions
bryanus1commented, Jul 28, 2021

I had the same problem, here is how I solved it.

In a docker container there is no need to create a virtual environment, since docker is akin to a virtual environment, so in a container we can pip install all packages globally. So when we spin up a container with a docker compose up, mapping an app folder from the host to a folder in a container, it is important to omit mapping the venv folder from the host, otherwise python gets confused, since now there is a symlink for app/venv/bin/python inside a container pointing to a python interpreter location from the host operating system. So a way to omit mapping venv from the host to a container is add this into docker-compose:

 volumes:
      - .:/app
      - app/venv/ # This line hides mapping of venv folder in the container

I test your solution and works without problems, only make a change that volume must be a absolutly path, change volumes: - .:/app - /app/venv/ add a / before app

2reactions
ruslanivcommented, Jul 23, 2021

I had the same problem, here is how I solved it.

In a docker container there is no need to create a virtual environment, since docker is akin to a virtual environment, so in a container we can pip install all packages globally. So when we spin up a container with a docker compose up, mapping an app folder from the host to a folder in a container, it is important to omit mapping the venv folder from the host, otherwise python gets confused, since now there is a symlink for app/venv/bin/python inside a container pointing to a python interpreter location from the host operating system. So a way to omit mapping venv from the host to a container is add this into docker-compose:

 volumes:
      - .:/app
      - app/venv/ # This line hides mapping of venv folder in the container
Read more comments on GitHub >

github_iconTop Results From Across the Web

Django container complains "error walking file system" when ...
This happens if you have a Python venv environment installed anywhere inside the project directory. The problem is, inside the docker container, ...
Read more >
Django container complains "error walking file system" when venv is ...
After creating a fresh project, and then docker-compose build and up , The Django Docker container infinitely complains "error walking file system". What...
Read more >
Can'not launch django installed inside docker - Stack Overflow
I am using Docker to launch my app which imports django. I want to do it inside my git repository. My Dockerfile looks...
Read more >
Installing Django on IIS: A Step-by-Step Tutorial - Toptal
In this article, Toptal Engineer Ivan Voras walks you through a step-by-step tutorial, clearly explaining how to install Django on IIS.
Read more >
Chapter 2: Hello World app | Django For Beginners
Create a new virtual environment called .venv , activate it, and install Django with Pip as we did in the previous chapter. #...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found