Skip to content

.dockerignore with '*' wildcard doesn't work as documented #585

@mcayland

Description

@mcayland
  • This is a bug report
  • This is a feature request
  • I searched existing issues before opening this one

Expected behavior

According to the documentation at https://docs.docker.com/engine/reference/builder/#dockerignore-file:

Finally, you may want to specify which files to include in the context, rather than which to exclude. To achieve this, specify * as the first pattern, followed by one or more ! exception patterns.

Using this .dockerignore file:

*
!docker/*/Dockerfile

I would expect that all files are excluded by default except the named Dockerfile.

Actual behavior

Using the above .dockerignore file, docker build complains that it cannot locate the named Dockerfile:

$ docker build . -f docker/application/Dockerfile 
Sending build context to Docker daemon  2.048kB
Error response from daemon: Cannot locate specified Dockerfile: docker/application/Dockerfile

Steps to reproduce the behavior

mkdir -p docker/application
echo "FROM tomcat:7.0.92-jre8" > docker/application/Dockerfile

echo "*" > ./.dockerignore
echo "!docker/*/Dockerfile" >> ./.dockerignore

docker build . -f docker/application/Dockerfile

Output of docker version:

Client:
 Version:           18.09.1
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        4c52b90
 Built:             Wed Jan  9 19:35:59 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       4c52b90
  Built:            Wed Jan  9 19:02:44 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

Containers: 26
 Running: 1
 Paused: 0
 Stopped: 25
Images: 112
Server Version: 18.09.1
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local                                                                                                                                                                                                                   
 Network: bridge host macvlan null overlay                                                                                                                                                                                       
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog                                                                                                                                             
Swarm: inactive                                                                                                                                                                                                                  
Runtimes: runc                                                                                                                                                                                                                   
Default Runtime: runc                                                                                                                                                                                                            
Init Binary: docker-init                                                                                                                                                                                                         
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce                                                                                                                                                                     
runc version: 96ec2177ae841256168fcf76954f7177af9446eb                                                                                                                                                                           
init version: fec3683                                                                                                                                                                                                            
Security Options:                                                                                                                                                                                                                
 seccomp                                                                                                                                                                                                                         
  Profile: default                                                                                                                                                                                                               
Kernel Version: 4.9.0-8-amd64                                                                                                                                                                                                    
Operating System: Debian GNU/Linux 9 (stretch)                                                                                                                                                                                   
OSType: linux                                                                                                                                                                                                                    
Architecture: x86_64                                                                                                                                                                                                             
CPUs: 4
Total Memory: 7.685GiB
Name: kentang
ID: 4SNI:INVE:W35N:4NNV:55J2:2J42:6ZLC:MZBU:US3R:V375:BCT7:TCNT
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.)

Physical (Debian Stretch amd64)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions