This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.DirEntry.inode() returns invalid value within Docker container
Type: behavior Stage: resolved
Components: Build Versions: Python 3.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: decaz, iritkatriel
Priority: normal Keywords:

Created on 2019-02-11 23:11 by decaz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg335275 - (view) Author: Marat Sharafutdinov (decaz) * Date: 2019-02-11 23:11
I'm trying to build Python 3.7.2 within official CentOS 7.6.1810 image (https://hub.docker.com/_/centos) and getting the following error during testing:

======================================================================
FAIL: test_attributes (test.test_os.TestScandir)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/src/python/Lib/test/test_os.py", line 3367, in test_attributes
    self.check_entry(entry, 'dir', True, False, False)
  File "/usr/src/python/Lib/test/test_os.py", line 3319, in check_entry
    os.stat(entry.path, follow_symlinks=False).st_ino)
AssertionError: 28093768 != 85098458

I guess this bug applies to Docker containers in general. For instance it's reproduced with the official Python 3.7.2-stretch image based on the Debian Stretch (https://hub.docker.com/_/python):

$ docker run --rm -it python:3.7.2-stretch
Python 3.7.2 (default, Feb  6 2019, 12:04:03) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.mkdir('/test_dir')
>>> for entry in os.scandir('/'):
...   if entry.name == 'test_dir':
...     break
... 
>>> print(entry, entry.inode(), os.stat(entry.path, follow_symlinks=False).st_ino)
<DirEntry 'test_dir'> 23898155 85118011
>>> assert entry.inode() == os.stat(entry.path, follow_symlinks=False).st_ino
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError
>>> 

In case of using host volume when running container it works ok, - the problem occurs when using default Docker volume:

$ docker run --rm -it -v /home/decaz/workspace:/host_dir python:3.7.2-stretch
Python 3.7.2 (default, Feb  6 2019, 12:04:03) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.mkdir('/host_dir/test_dir')
>>> for entry in os.scandir('/host_dir'):
...   if entry.name == 'test_dir':
...     break
... 
>>> print(entry, entry.inode(), os.stat(entry.path, follow_symlinks=False).st_ino)
<DirEntry 'test_dir'> 12873222 12873222
>>> assert entry.inode() == os.stat(entry.path, follow_symlinks=False).st_ino
>>> 

Similar issue - https://bugs.python.org/issue32811.
msg410705 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-16 18:08
3.7 is no longer maintained. Please create a new issue if you are seeing this on a current python version (>= 3.9).
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80155
2022-01-16 18:08:43iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg410705

resolution: out of date
stage: resolved
2019-02-11 23:11:22decazcreate