[Django] #30647: [FATAL] FileNotFoundError with runserver command inside Docker container

23 views
Skip to first unread message

Django

unread,
Jul 18, 2019, 12:18:31β€―AM7/18/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
steinbachr |
Type: Bug | Status: new
Component: | Version: 2.2
Uncategorized | Keywords: docker docker-
Severity: Normal | compose autoreload
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
**Summary**
Trying to run the development server in a container with volume-mounted
source is throwing a FileNotFoundError. I've verified that the issue is
consistently reproducible with Django==2.2.3 and not present in
Django==2.1.4.

**Trace**

{{{
**INFO** /code/publications/models.py changed, reloading.
**INFO** Watching for file changes with StatReloader
Performing system checks...

Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/__init__.py", line 381, in
execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-
packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/commands/runserver.py", line 60, in
execute
super().execute(*args, **options)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/usr/local/lib/python3.6/site-
packages/django/utils/autoreload.py", line 587, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/usr/local/lib/python3.6/site-
packages/django/utils/autoreload.py", line 572, in start_django
reloader.run(django_main_thread)
File "/usr/local/lib/python3.6/site-
packages/django/utils/autoreload.py", line 289, in run
autoreload_started.send(sender=self)
File "/usr/local/lib/python3.6/site-
packages/django/dispatch/dispatcher.py", line 175, in send
for receiver in self._live_receivers(sender)
File "/usr/local/lib/python3.6/site-
packages/django/dispatch/dispatcher.py", line 175, in <listcomp>
for receiver in self._live_receivers(sender)
File "/usr/local/lib/python3.6/site-
packages/django/utils/translation/reloader.py", line 16, in
watch_for_translation_changes
absolute_path = path.absolute()
File "/usr/local/lib/python3.6/pathlib.py", line 1129, in absolute
obj = self._from_parts([os.getcwd()] + self._parts, init=False)
FileNotFoundError: [Errno 2] No such file or directory
}}}

**Configuration**
''Dockerfile''

{{{
FROM python:3.6.7-alpine3.7

RUN mkdir /code

WORKDIR /code

RUN apk add postgresql-dev libffi-dev build-base musl-dev
RUN apk add linux-headers

ADD requirements.txt .

RUN pip install -r requirements.txt

EXPOSE 3031

ADD cs /code
}}}

''docker-compose''

{{{
version: '3.7'
services:
db:
image: postgres
volumes:
- ./pg_data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres

app:
build:
context: .
volumes:
- ./cs/:/code/
ports:
- "8000:8000"
env_file: .env
command: ["python", "manage.py", "runserver", "0.0.0.0:8000"]
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30647>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 18, 2019, 1:22:56β€―AM7/18/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: steinbachr | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution:
Keywords: docker docker- | Triage Stage:
compose autoreload | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* cc: Tom Forbes (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:1>

Django

unread,
Jul 18, 2019, 3:58:17β€―AM7/18/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: steinbachr | Owner: nobody
Type: Bug | Status: new

Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution:
Keywords: docker docker- | Triage Stage:
compose autoreload | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

First glance, this looks like some Docker weirdness:

{{{


File "/usr/local/lib/python3.6/site-
packages/django/utils/translation/reloader.py", line 16, in
watch_for_translation_changes
absolute_path = path.absolute()
File "/usr/local/lib/python3.6/pathlib.py", line 1129, in absolute
obj = self._from_parts([os.getcwd()] + self._parts, init=False)
FileNotFoundError: [Errno 2] No such file or directory
}}}

That's a standard library call raising the error, so why's that not
working?

@steinbachr it would be helpful if you could put a breakpoint in there and
try to work out exactly what's going on. (That call should work. Why isn't
it? Is there an obvious something that would?)

Why the ''regression'' between 2.1 and 2.2? We were using `os.path`
previously I guess... Still, this should be something that works, so a bit
more digging is needed.

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:2>

Django

unread,
Jul 18, 2019, 4:05:56β€―AM7/18/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: steinbachr | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 2.2

Severity: Normal | Resolution:
Keywords: docker docker- | Triage Stage:
compose autoreload | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* component: Uncategorized => Core (Other)


--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:3>

Django

unread,
Jul 18, 2019, 4:09:13β€―AM7/18/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: steinbachr | Owner: nobody
Type: Bug | Status: new

Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution:
Keywords: docker docker- | Triage Stage:
compose autoreload | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tom Forbes):

Is this while using Docker for Mac? Could it be related to this Docker
issue, as it seems it’s being thrown in the cwd call:

https://github.com/docker/for-mac/issues/1509

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:4>

Django

unread,
Jul 18, 2019, 5:46:42β€―AM7/18/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: steinbachr | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution: needsinfo

Keywords: docker docker- | Triage Stage:
compose autoreload | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => needsinfo


Comment:

I'm thinking to close this as `needsinfo` for the moment. I'm very happy
to re-open it if we can show that Django is at fault. Or if we want to
provide a workaround in any case... (β€” Tom, happy to follow your lead
there.)

@steinbachr please do add the extra information. I do mean the "very happy
to re-open" :) Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:5>

Django

unread,
Jul 18, 2019, 10:59:14β€―PM7/18/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: Bobby Steinbach | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution: needsinfo
Keywords: docker docker- | Triage Stage:
compose autoreload | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Bobby Steinbach):

@Tom Forbes on my machine it is happening all the time. I can change my
requirements to downgrade to Django==2.1.4 and rebuild the image,
resulting in a working container. Then, I can upgrade to Django==2.2.3 and
rebuild, resulting in a broken container, consistently.

Some system information:

Mac OS Version: 10.13.6 (High Sierra)
Docker version 18.09.2, build 6247962
docker-compose version 1.23.2, build 1110ad01

Let me know if there's any additional info I can provide to help

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:6>

Django

unread,
Jul 21, 2019, 5:47:25β€―PM7/21/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: Bobby Steinbach | Owner: nobody
Type: Bug | Status: new

Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution:
Keywords: docker docker- | Triage Stage: Accepted
compose autoreload |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tom Forbes):

* status: closed => new
* resolution: needsinfo =>
* stage: Unreviewed => Accepted


Comment:

I'm going to re-open this Carlton, if that's OK. While this isn't Django's
fault, it is a regression since 2.1 and it apparently does happen
reproducibly.

Patch: https://github.com/django/django/pull/11584

Bobby: I would absolutely love if you could find some time to test this
patch. It should be pretty simple, if you can run:


{{{
python -mpip install https://github.com/orf/django/archive/test-file-not-
found.zip
}}}

Unfortunately this will be a 100+mb tarball (as it includes the whole
repository history), but it's the latest 2.2x branch with my patch
applied. Please let me know if the issue still occurs!

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:7>

Django

unread,
Jul 21, 2019, 5:47:37β€―PM7/21/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: Bobby Steinbach | Owner: Tom
| Forbes
Type: Bug | Status: assigned

Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution:
Keywords: docker docker- | Triage Stage: Accepted
compose autoreload |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tom Forbes):

* owner: nobody => Tom Forbes
* status: new => assigned
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:8>

Django

unread,
Jul 22, 2019, 1:09:34β€―AM7/22/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: Bobby Steinbach | Owner: Tom
| Forbes
Type: Bug | Status: assigned
Component: Core (Other) | Version: 2.2
Severity: Release blocker | Resolution:

Keywords: docker docker- | Triage Stage: Accepted
compose autoreload |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* severity: Normal => Release blocker


--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:9>

Django

unread,
Jul 22, 2019, 2:26:09β€―AM7/22/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: Bobby Steinbach | Owner: Tom
| Forbes
Type: Bug | Status: assigned
Component: Core (Other) | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: docker docker- | Triage Stage: Accepted
compose autoreload |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

> I'm going to re-open this Carlton, if that's OK.

Absolutely Tom! That was the hope. πŸ™‚

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:10>

Django

unread,
Jul 22, 2019, 12:30:21β€―PM7/22/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: Bobby Steinbach | Owner: Tom
| Forbes
Type: Bug | Status: assigned
Component: Core (Other) | Version: 2.2
Severity: Release blocker | Resolution:
Keywords: docker docker- | Triage Stage: Accepted
compose autoreload |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Bobby Steinbach):

Tom, I'll give that a try now and report back.

Replying to [comment:7 Tom Forbes]:


> I'm going to re-open this Carlton, if that's OK. While this isn't
Django's fault, it is a regression since 2.1 and it apparently does happen
reproducibly.
>
> Patch: https://github.com/django/django/pull/11584
>
> Bobby: I would absolutely love if you could find some time to test this
patch. It should be pretty simple, if you can run:
>
>
> {{{
> python -mpip install https://github.com/orf/django/archive/test-file-
not-found.zip
> }}}
>
> Unfortunately this will be a 100+mb tarball (as it includes the whole
repository history), but it's the latest 2.2x branch with my patch
applied. Please let me know if the issue still occurs!

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:11>

Django

unread,
Jul 24, 2019, 8:35:26β€―AM7/24/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: Bobby Steinbach | Owner: Tom
| Forbes
Type: Bug | Status: closed

Component: Core (Other) | Version: 2.2
Severity: Release blocker | Resolution: fixed

Keywords: docker docker- | Triage Stage: Accepted
compose autoreload |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"fc75694257b5bceab82713f84fe5a1b23d641c3f" fc756942]:
{{{
#!CommitTicketReference repository=""
revision="fc75694257b5bceab82713f84fe5a1b23d641c3f"
Fixed #30647 -- Fixed crash of autoreloader when extra directory cannot be
resolved.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:12>

Django

unread,
Jul 24, 2019, 8:40:16β€―AM7/24/19
to django-...@googlegroups.com
#30647: [FATAL] FileNotFoundError with runserver command inside Docker container
-------------------------------------+-------------------------------------
Reporter: Bobby Steinbach | Owner: Tom
| Forbes
Type: Bug | Status: closed
Component: Core (Other) | Version: 2.2
Severity: Release blocker | Resolution: fixed
Keywords: docker docker- | Triage Stage: Accepted
compose autoreload |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"4d6449e1258c88b6e4e1ccbb5e84b210371598d2" 4d6449e1]:
{{{
#!CommitTicketReference repository=""
revision="4d6449e1258c88b6e4e1ccbb5e84b210371598d2"
[2.2.x] Fixed #30647 -- Fixed crash of autoreloader when extra directory
cannot be resolved.

Backport of fc75694257b5bceab82713f84fe5a1b23d641c3f from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30647#comment:13>

Reply all
Reply to author
Forward
0 new messages