weixin_39788051
weixin_39788051
2021-01-09 08:03

Buildah fails when the base image has symlink with the same name as a VOLUME

Description

Well, I'm not sure if this is considered a bug or not, as it can be argued that the Dockerfile itself can be rewritten in a better way, but here goes:

buildah bud / podman build fails when the base image or previous layer has a symlink with the same name as a VOLUME. Similar to #1439 but with different behavior.

Steps to reproduce the issue:

Let's take a look at three Dockerfiles:

Dockerfile A: Docker :heavy_check_mark: | podman build :heavy_check_mark: | buildah bud :heavy_check_mark:


FROM alpine
RUN ln -s /anything /data
VOLUME /data

Dockerfile B: Docker :heavy_check_mark: | podman build :x: | buildah bud :heavy_check_mark:


FROM alpine
RUN ln -s /anything /data
VOLUME /data

# RUN with such VOLUME, in the same Dockerfile
RUN ls -lah / && cat /proc/mounts

Dockerfile C: Docker :heavy_check_mark: | podman build :x: | buildah bud :x:


FROM A

# RUN with such VOLUME in the base image
RUN ls -lah / && cat /proc/mounts

Describe the results you received:

At the final RUN, podman build / buildah bud (if it fails according to above) will complain:


Error: error building at STEP "RUN ls -lah / && cat /proc/mounts": error resolving mountpoints for container "e8980bb5cdefb7ccee47982456d158aa7de59608c35cc25cd051c4dca9bfbb24": error creating directory "/var/lib/containers/storage/overlay/d3e2d8e9045d3eb8d65d2e18c3a57b4dc4d2a5ca385a43ce8292ab3be044b495/merged/data" for volume "/data": mkdir /var/lib/containers/storage/overlay/d3e2d8e9045d3eb8d65d2e18c3a57b4dc4d2a5ca385a43ce8292ab3be044b495/merged/data: file exists

An example of such a base image in the wild is octoprint/octoprint:


STEP 1: FROM octoprint/octoprint:1.4.2
STEP 2: RUN echo 'do anything'
Error: error building at STEP "RUN echo 'do anything'": error resolving mountpoints for container "e551ad6714d5c2e4d954afeca98f03fd5b8956d6453d850fedc9466657ff59d9": error creating directory "/var/lib/containers/storage/overlay/169474d3bc1174f339e997db7f85aacc6734e449a60356260087e097a989a015/merged/octoprint" for volume "/octoprint": mkdir /var/lib/containers/storage/overlay/169474d3bc1174f339e997db7f85aacc6734e449a60356260087e097a989a015/merged/octoprint: file exists

Describe the results you expected:

The build succeeds as with Docker, with the symlink staying as a symlink throughout the whole build process.

Output of rpm -q buildah or apt list buildah:


$ yay -Qi buildah
Name            : buildah
Version         : 1.16.1-1
Description     : A tool which facilitates building OCI images
Architecture    : x86_64
URL             : https://github.com/containers/buildah
Licenses        : Apache
Groups          : None
Provides        : None
Depends On      : runc  skopeo  slirp4netns
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 25.43 MiB
Packager        : Morten Linderud <foxboron.org>
Build Date      : Fri 11 Sep 2020 11:12:24 AM PDT
Install Date    : Tue 15 Sep 2020 10:41:31 AM PDT
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature
</foxboron.org>

Output of buildah version:


Version:         1.16.1
Go Version:      go1.15.2
Image Spec:      1.0.1-dev
Runtime Spec:    1.0.2-dev
CNI Spec:        0.4.0
libcni Version:  v0.7.2-0.20190904153231-83439463f784
image Version:   5.5.2
Git Commit:      0de2694a
Built:           Fri Sep 11 11:12:24 2020
OS/Arch:         linux/amd64

Output of podman version if reporting a podman build issue:


Version:      2.0.6
API Version:  1
Go Version:   go1.15
Git Commit:   27362ba1ad8879ea71610fa68a651a1651e0180f
Built:        Tue Sep  1 12:43:39 2020
OS/Arch:      linux/amd64

Output of cat /etc/*release:


LSB_VERSION=1.4
DISTRIB_ID=Arch
DISTRIB_RELEASE=rolling
DISTRIB_DESCRIPTION="Arch Linux"
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://www.archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux

Output of uname -a:


Linux zorro 5.8.2-arch1-1 #1 SMP PREEMPT Thu, 20 Aug 2020 20:45:00 +0000 x86_64 GNU/Linux

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


# This file is is the configuration file for all tools
# that use the containers/storage library.
# 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]
# Storage options to be passed to underlying storage drivers

# 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.
size = ""

# Path to an helper program to use for mounting the file system instead of mounting it
# directly.
#mount_program = "/usr/bin/fuse-overlayfs"

# OverrideKernelCheck tells the driver to ignore kernel checks based on kernel version
override_kernel_check = "true"

# mountopt specifies comma separated list of extra mount options
mountopt = "nodev"

# Remap-UIDs/GIDs is the mapping from UIDs/GIDs as they should appear inside of
# a container, to UIDs/GIDs as they should appear outside of the container, and
# the length of the range of UIDs/GIDs.  Additional mapped sets can be listed
# and will be heeded by libraries, but there are limits to the number of
# mappings which the kernel will allow when you later attempt to run a
# container.
#
# remap-uids = 0:1668442479:65536
# remap-gids = 0:1668442479:65536

# Remap-User/Group is a name which can be used to look up one or more UID/GID
# ranges in the /etc/subuid or /etc/subgid file.  Mappings are set up starting
# with an in-container ID of 0 and the a host-level ID taken from the lowest
# range that matches the specified name, and using the length of that range.
# Additional ranges are then assigned, using the ranges which specify the
# lowest host-level IDs first, to the lowest not-yet-mapped container-level ID,
# until all of the entries have been used for maps.
#
# remap-user = "storage"
# remap-group = "storage"

[storage.options.thinpool]
# Storage Options for thinpool

# autoextend_percent determines the amount by which pool needs to be
# grown. This is specified in terms of % of pool size. So a value of 20 means
# that when threshold is hit, pool will be grown by 20% of existing
# pool size.
# autoextend_percent = "20"

# autoextend_threshold determines the pool extension threshold in terms
# of percentage of pool size. For example, if threshold is 60, that means when
# pool is 60% full, threshold has been hit.
# autoextend_threshold = "80"

# basesize specifies the size to use when creating the base device, which
# limits the size of images and containers.
# basesize = "10G"

# blocksize specifies a custom blocksize to use for the thin pool.
# blocksize="64k"

# directlvm_device specifies a custom block storage device to use for the
# thin pool. Required if you setup devicemapper.
# directlvm_device = ""

# directlvm_device_force wipes device even if device already has a filesystem.
# directlvm_device_force = "True"

# fs specifies the filesystem type to use for the base device.
# fs="xfs"

# log_level sets the log level of devicemapper.
# 0: LogLevelSuppress 0 (Default)
# 2: LogLevelFatal
# 3: LogLevelErr
# 4: LogLevelWarn
# 5: LogLevelNotice
# 6: LogLevelInfo
# 7: LogLevelDebug
# log_level = "7"

# min_free_space specifies the min free space percent in a thin pool require for
# new device creation to succeed. Valid values are from 0% - 99%.
# Value 0% disables
# min_free_space = "10%"

# mkfsarg specifies extra mkfs arguments to be used when creating the base.
# device.
# mkfsarg = ""

# use_deferred_removal marks devicemapper block device for deferred removal.
# If the thinpool is in use when the driver attempts to remove it, the driver 
# tells the kernel to remove it as soon as possible. Note this does not free
# up the disk space, use deferred deletion to fully remove the thinpool.
# use_deferred_removal = "True"

# use_deferred_deletion marks thinpool device for deferred deletion.
# If the device is busy when the driver attempts to delete it, the driver
# will attempt to delete device every 30 seconds until successful.
# If the program using the driver exits, the driver will continue attempting
# to cleanup the next time the driver is used. Deferred deletion permanently
# deletes the device and all data stored in device will be lost.
# use_deferred_deletion = "True"

# xfs_nospace_max_retries specifies the maximum number of retries XFS should
# attempt to complete IO when ENOSPC (no space) error is returned by
# underlying storage device.
# xfs_nospace_max_retries = "0"

# If specified, use OSTree to deduplicate files with the overlay backend
ostree_repo = ""

# Set to skip a PRIVATE bind mount on the storage home directory.  Only supported by
# certain container storage drivers
skip_mount_home = "false"

该提问来源于开源项目:containers/buildah

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39961943 weixin_39961943 4月前

    On a quick glance these look like bugs to me. Care to take a look to attempt to fix them?

    点赞 评论 复制链接分享
  • weixin_39788051 weixin_39788051 4月前

    Sure, I'll take a look later today.

    点赞 评论 复制链接分享
  • weixin_39615956 weixin_39615956 4月前

    thanks for the issue and thorough investigation. One really quick note, for sample B, I'm going to guess that if you added the option --layers to the buildah bud command, then that would fail as the podman build command did. I can't give you quick pointers on this, but I'm guessing this will be an "entertaining" fix, hopefully I'm wrong here. But you're right, all of those builds that you showed should work without error.

    点赞 评论 复制链接分享
  • weixin_39788051 weixin_39788051 4月前

    It ended up being a really simple fix :smile: And yes, I replicated the same issue by adding --layers to buildah bud.

    点赞 评论 复制链接分享
  • weixin_39615956 weixin_39615956 4月前

    awesome! I guess thinking it would not be an easy fix is due to me being a "doubting Thomas"! Thanks for looking into this.

    点赞 评论 复制链接分享

相关推荐