Invalid symlinks now break utils.create_archive(), previously were skipped, skipped by docker CLI
zdw opened this issue · 2 comments
zdw commented
Version 2.7.0 seems to die if you try to include a symlink that points to something that doesn't exist. This problem seems to have been introduced in this commit:
5c57050
Example from 2.6.1 and docker
cli tool:
$ mkdir test
$ cd test
$ ln -s /doesnt_exist doesnt_exist
$ cat << EOF > Dockerfile
FROM scratch
COPY . /tmp
EOF
$ docker build -t test .
Sending build context to Docker daemon 2.56kB
Step 1/2 : FROM scratch
--->
Step 2/2 : COPY . /tmp
---> cb6f16dc4b1f
Removing intermediate container 4eda4dd7d7c4
Successfully built cb6f16dc4b1f
Successfully tagged test:latest
$ python
Python 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> docker.__version__
'2.6.1'
>>> docker.utils.create_archive(".", ['doesnt_exist'])
<open file '<fdopen>', mode 'w+b' at 0x7fa47208f8a0>
>>>
But as of 2.7.0:
$ python
Python 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> docker.__version__
'2.7.0'
>>> docker.utils.create_archive(".", ['doesnt_exist'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/docker/utils/utils.py", line 103, in create_archive
'Can not access file in context: {}'.format(full_path)
IOError: Can not access file in context: ./doesnt_exist
>>>
It seems that symlinks should be skipped rather than trying to checked to see if they are accessible, as was the previous behavior and the docker
CLI tool behavior.
Fiser12 commented
I have this same problem, for the moment I will have to pull that version
HemilTheRebel commented
Had a similar problem in a python project. Added .pytest_cache and venv to docker ignore and it worked