Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for .dockerignore #265

Closed
hamiltont opened this issue Jul 8, 2014 · 22 comments · Fixed by #268
Closed

Support for .dockerignore #265

hamiltont opened this issue Jul 8, 2014 · 22 comments · Fixed by #268

Comments

@hamiltont
Copy link

According to https://docs.docker.com/reference/builder/#dockerignore you can have a .dockerignore file that prevents items from being ADDed. Mine looks like this:

.git

And then in my Dockerfile I have

ADD . /root/mycodes/

Unfortunately I still see /root/mycodes/.git in my container, which is sad because it's almost 300M. Is there any way to support this?

@vieux
Copy link

vieux commented Jul 8, 2014

@hamiltont Are you using 1.1.0 ?

@hamiltont
Copy link
Author

Yes, and just running a sudo docker build . works as expected. Running the same build command from docker-py does not

@hamiltont
Copy link
Author

For reference:

hamiltont@3:/localhdd$ sudo docker info
Containers: 6
Images: 37
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Dirs: 49
Execution Driver: native-0.2
Kernel Version: 3.11.0-24-generic
WARNING: No swap limit support
hamiltont@3:/localhdd$ sudo docker version
Client version: 1.1.0
Client API version: 1.13
Go version (client): go1.2.1
Git commit (client): 79812e3
Server version: 1.1.0
Server API version: 1.13
Go version (server): go1.2.1
Git commit (server): 79812000

@vieux
Copy link

vieux commented Jul 8, 2014

@hamiltont what are the permission of your .dockerignore file ? can you paste us a ls -la please ?

@vieux
Copy link

vieux commented Jul 8, 2014

@hamiltont also, please paste us the output of sudo docker -D build .

@hamiltont
Copy link
Author

hamiltont@3:/localhdd$ ls -la | grep dock
-rw-rw-r--   1 hamiltont hamiltont       5 Jul  7 23:26 .dockerignore

Here you go. It should not be relevant, but my cwd when I call c.build is different from the path I provide to c.build(path=foo).

hamiltont@3:/localhdd$ sudo docker -D build . | tee output.log
[debug] archive.go:350 Skipping excluded path: .git
Sending build context to Docker daemon 263.8 MB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:14.04
 ---> e54ca5efa2e9
Step 1 : RUN locale-gen en_US.UTF-8
 ---> Running in e5b6ad76d8e5
Generating locales...
  en_US.UTF-8... done
Generation complete.
 ---> 21733509e288
Removing intermediate container e5b6ad76d8e5
Step 2 : ENV LANG en_US.UTF-8
 ---> Running in aa17977bfe5a
<snip>

@vieux
Copy link

vieux commented Jul 8, 2014

@hamiltont sorry to ask, but are you sure you test the right image ?
We can see [debug] archive.go:350 Skipping excluded path: .git so it is skipped.

@hamiltont
Copy link
Author

I mentioned above that it works correctly if I run sudo build $MYPATH myself, the problem is that when I run c.build(path=mypath) the .dockerignore file has no effect.

@hamiltont
Copy link
Author

I wonder if this tar function is the culprit. Is it successfully including .dockerignore in the tarred context?

EDIT: Don't think that is it, the .dockerignore file is still inside the container that I build with docker-py

@vieux
Copy link

vieux commented Jul 8, 2014

@hamiltont oh sorry I thought we were in the docker repo, not docker-py :)

ping @shin-

@hamiltont
Copy link
Author

ha ha, I was wondering...

I'm thinking the issue is that the client needs to detect .dockerignore, build a list of excludes, and ensure the are not tarred into the context. docker probably does this in go, but docker-py probably needs to be trained to look for a .dockerignore file and react to it. tarfile has a filter option that would do nicely

@shin-
Copy link
Contributor

shin- commented Jul 8, 2014

Yes, I'm guessing this is implemented on the client side in Go, so it needs to be rewritten in Python. :)

@bfirsh
Copy link
Contributor

bfirsh commented Jul 9, 2014

There's an implementation here: docker/compose#294

@zedtux
Copy link

zedtux commented Aug 27, 2014

When a release will be created including this fix ?

@ricardosasilva
Copy link

I'm using the Ansible docker module (http://docs.ansible.com/docker_image_module.html) and having the same problem. This fix would be fantastic.

@shin-
Copy link
Contributor

shin- commented Sep 5, 2014

I'll make it happen this weekend, or Monday at the latest.

@shreyaskarnik
Copy link
Contributor

👍

@hamiltont
Copy link
Author

thanks @shin- and @brutasse !

@ricardosasilva
Copy link

Nice!! Thanks @shin!

@shin-
Copy link
Contributor

shin- commented Sep 8, 2014

docker-py==0.5.0 is now available on pypi, thanks everyone for your patience!

@shreyaskarnik
Copy link
Contributor

👍 thanks @shin-

@ricardosasilva
Copy link

Thank you @shin!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants