containers / buildah

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

Instructions in blog building-buildah-container-image-for-kubernetes does not work on CentOS 7 #1617

Closed dove-young closed 5 years ago

dove-young commented 5 years ago

Description

Instructions in this blog does not work on CentOS 7

https://buildah.io/blogs/2018/03/01/building-buildah-container-image-for-kubernetes.html

Steps to reproduce the issue:

  1. containerid=$(buildah from scratch)
  2. scratchmnt=$(buildah mount $containerid)
  3. yum install --nogpgcheck --installroot $scratchmnt --release 7 buildah --setopt install_weak_deps=false -y
  4. yum clean all --installroot $scratchmnt --releasever 7
  5. buildah config --entrypoint /usr/bin/buildah $containerid
  6. buildah commit $containerid buildah
  7. podman run localhost/buildah version then hit error result.

I can workaround this by change --entrypoint /usr/bin/buildah to --entrypoint '["/usr/bin/buildah"]' in step 5.

With --entrypoint /usr/bin/buildah parameter, the actual result created is as below and it does not work actually.

"Entrypoint": [ "/bin/sh",
                "-c",
                "/usr/bin/buildah"
]

And /bin/sh -c /usr/bin/buildah version does not work yet on my system. So I must change entrypoint to --entrypoint '["/usr/bin/buildah"]' to get it work.

Describe the results you received:

podman run localhost/buildah version                                                                 A tool that facilitates building OCI images

Usage:                                                                                                               buildah [flags]
  buildah [command]
                                                                                                                   Available Commands:
  add                    Add content to the container
  build-using-dockerfile Build an image using instructions in a Dockerfile
  commit                 Create an image from a working container
  config                 Update image configuration settings
  containers             List working containers and their base images
  copy                   Copy content into the container
  from                   Create a working container based on an image
  help                   Help about any command
  images                 List images in local storage
  info                   Display Buildah system information
  inspect                Inspect the configuration of a container or image
  mount                  Mount a working container's root filesystem
  pull                   Pull an image from the specified location
  push                   Push an image to a specified destination
  rename                 Rename a container                                                                          rm                     Remove one or more working containers                                                       rmi                    Remove one or more images from local storage
  run                    Run a command inside of the container
  tag                    Add an additional name to a local image
  umount                 Unmount the root file system of the specified working containers
  unshare                Run a command in a modified user namespace
  version                Display the Buildah version information

Flags:
      --debug                                print debugging information
  -h, --help                                 help for buildah
      --registries-conf string               path to registries.conf file (not usually used)
      --registries-conf-dir string           path to registries.conf.d directory (not usually used)
      --root string                          storage root dir (default "/var/lib/containers/storage")
      --runroot string                       storage state dir (default "/var/run/containers/storage")
      --storage-driver string                storage-driver (default "overlay")
      --storage-opt strings                  storage driver option
      --userns-gid-map ctrID:hostID:length   default ctrID:hostID:length GID mapping to use
      --userns-uid-map ctrID:hostID:length   default ctrID:hostID:length UID mapping to use
      --version                              version for buildah

Use "buildah [command] --help" for more information about a command.

Describe the results you expected:

podman run localhost/buildah version
Version:         1.7.1
Go Version:      go1.10.3
Image Spec:      1.0.0
Runtime Spec:    1.0.0
CNI Spec:        0.4.0
libcni Version:  v0.7.0-alpha1
Git Commit:      93747b1                                                                                           Built:           Wed May  1 14:53:57 2019                                                                          OS/Arch:         linux/amd64

Output of rpm -q buildah or apt list buildah:

buildah-1.7.1-2.git93747b1.el7.centos.x86_64

Output of buildah version:

Version:         1.7.1
Go Version:      go1.10.3
Image Spec:      1.0.0
Runtime Spec:    1.0.0
CNI Spec:        0.4.0
libcni Version:  v0.7.0-alpha1
Git Commit:      93747b1
Built:           Wed May  1 22:53:57 2019
OS/Arch:         linux/amd64

Output of podman version if reporting a podman build issue:

Version:       0.12.1.2
Go Version:    go1.10.3
OS/Arch:       linux/amd64

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

NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

Output of uname -a:

Linux coc-cam-2 3.10.0-862.3.3.el7.x86_64 #1 SMP Fri Jun 15 04:15:27 UTC 2018 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]
# 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 = ""

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

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

# mountopt specifies extra mount options used when mounting the thin devices.
# mountopt = ""

# use_deferred_removal Marking device for deferred removal
# use_deferred_removal = "True"

# use_deferred_deletion Marking device for deferred deletion
# 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"
podman run localhost/buildah version
Version:         1.7.1
Go Version:      go1.10.3
Image Spec:      1.0.0
Runtime Spec:    1.0.0
CNI Spec:        0.4.0
libcni Version:  v0.7.0-alpha1
Git Commit:      93747b1
Built:           Wed May  1 14:53:57 2019
OS/Arch:         linux/amd64
dove-young commented 5 years ago

And the command to build Nginx from Dockerfile does not work yet.

podman run --privileged --network host -v /var/lib/containers:/var/lib/containers:rw  -v /root/buildah/nginx:/tmp:Z buildah bud -f /tmp/Dockerfile -t nginx
no context directory or URL specified

To have it works on my system I must put the suffix . on the command

podman run --privileged --network host -v /var/lib/containers:/var/lib/containers:rw  -v /root/buildah/nginx:/tmp:Z buildah bud -f /tmp/Dockerfile -t nginx .
TomSweeneyRedHat commented 5 years ago

@dove-young thanks for raising the issue. @ipbabble this appears to be one of your blogs, can you PTAL?

rhatdan commented 5 years ago

This is really not a buildah bug, But a blog bug closing.