I have a python shelve file generated with python 3.4 and UTF-8 encoding. The file can be opened and accessed fine on the host. When I access the file inside a python:3.4 Docker container, I get
>>> shelve.open('data/countries.shelf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/shelve.py", line 243, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/local/lib/python3.4/shelve.py", line 227, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/usr/local/lib/python3.4/dbm/__init__.py", line 94, in open
return mod.open(file, flag, mode)
_gdbm.error: Bad magic number
It does not make any difference whether the file is bind-mounted into the container or actually copied during build, the error is the same.
I also compared the md5sum
of the file outside and inside the container and they are identical (as I was expecting). But if the files are identical, how can the magic number be different?