containers / buildah

A tool that facilitates building OCI images.
https://buildah.io
Apache License 2.0
7.41k stars 783 forks source link

COPY misbehaves in the presence of any non-empty .dockerignore file #1530

Closed undecaf closed 5 years ago

undecaf commented 5 years ago

When COPYing a directory, I expected only the children of the source directory to be copied. However, if a non-empty .dockerignore file exists then the source directory itself is copied.

Steps to reproduce the issue:

  1. Create this Dockerfile:
    FROM alpine:edge
    COPY zzz /
    RUN find / -maxdepth 2 -name 'zzz*'
  2. Create this source directory structure in the context:
    
    zzz/
    └── etc/
    └── zzz.conf

mkdir -p zzz/etc touch zzz/etc/zzz.conf

3. Create this `.dockerignore` file (actually, any content except `#` will do):

X

echo X > .dockerignore

4. Run `podman build .`

**Describe the results you received:**
Directory `zzz` appears at the image root:

STEP 4: RUN find / -maxdepth 2 -name 'zzz*' /zzz


**Describe the results you expected:**
The content of `zzz` was merged into the image (this will happen when building with  `.dockerignore` removed or empty):

STEP 4: RUN find / -maxdepth 2 -name 'zzz*' /etc/zzz.conf


**Output of `rpm -q buildah` or `apt list buildah`:**

buildah/bionic,now 1.8-1~dev~ubuntu18.04~ppa24 amd64 [installiert]


**Output of `buildah version`:**

Version: 1.8-dev Go Version: go1.10.4 Image Spec: 1.0.0 Runtime Spec: 1.0.0 CNI Spec: 0.4.0 libcni Version:
Git Commit:
Built: Wed Apr 17 01:15:37 2019 OS/Arch: linux/amd64


**Output of `podman version` if reporting a `podman build` issue:**

Version: 1.3.0-dev RemoteAPI Version: 1 Go Version: go1.10.4 OS/Arch: linux/amd64

apt-cache policy podman => 1.3.0-1~dev~ubuntu18.04~ppa15


**Output of `cat /etc/*release`:**

DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS" NAME="Ubuntu" VERSION="18.04.2 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.2 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic


**Output of `uname -a`:**

Linux hestia 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux


**Output of `cat /etc/containers/storage.conf`:**

storage.conf is the configuration file for all tools

that share the containers/storage libraries

See man 5 containers-storage.conf for more information

The "container storage" table contains all of the server options.

[storage]

Default Storage Driver

driver = "overlay"

Temporary storage location

runroot = "/var/run/containers/storage"

Primary read-write location of container storage

graphroot = "/var/lib/containers/storage"

[storage.options]

AdditionalImageStores is used to pass paths to additional read-only image stores

Must be comma separated list.

additionalimagestores = [ ]

Size is used to set a maximum size of the container image. Only supported by

certain container storage drivers (currently overlay, zfs, vfs, btrfs)

size = ""

OverrideKernelCheck tells the driver to ignore kernel checks based on kernel version

override_kernel_check = "true"

TomSweeneyRedHat commented 5 years ago

@QiWang19 PTAL

QiWang19 commented 5 years ago

Bot doesn't close this for me. I'll close it.

undecaf commented 5 years ago

@QiWang19 I did not close this myself since I intended to wait until the bugfix arrives in buildah/bionic. The most recent version at projectatomic/ppa (1.8-1\~dev\~ubuntu18.04\~ppa25) is not fixed.

QiWang19 commented 5 years ago

:ok_hand: , I'll reopen.

undecaf commented 5 years ago

@QiWang19 Thank you!

undecaf commented 5 years ago

Unfortunately not yet solved in the current Ubuntu Bionic version: buildah/bionic 1.9.0-1\~dev\~ubuntu18.04\~ppa4 amd64

undecaf commented 5 years ago

@QiWang19 Could you please reopen this? buildah still behaves as described above. Thanks!

QiWang19 commented 5 years ago

@undecaf thanks. It's open already

undecaf commented 5 years ago

I am sorry for the mess, I was mistaken, this is no longer a Buildah bug: buildah bud . yields the correct result:

STEP 3: RUN find / -maxdepth 2 -name 'zzz*'
/etc/zzz.conf

whereas podman build . still gives the wrong result (Podman 1.3.0-1\~dev\~ubuntu18.04\~ppa20):

STEP 3: RUN find / -maxdepth 2 -name 'zzz*'
/zzz

I did not test Buildah in the first place because I thought that podman build uses the installed Buildah instance, but apparently it does not. Closing this one and opening at containers/libpod

rhatdan commented 5 years ago

Yes podman build is a vendored version of buildah, meaning it pulls in an older version of buildah code base and compiles it into podman. You can use podman info | grep -i buildah to get the version of buildah used.