containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.38k stars 208 forks source link

Container created from non-Toolbx fedora image doesn't start due to the absence of passwd(1) #1433

Closed kavishgr closed 5 months ago

kavishgr commented 6 months ago

Describe the bug

Getting the following error when entering a toolbox container with toolbox enter:

Error: failed to initialize container fedora

Podman logs says (Error: failed to remove password for root: passwd(1) not found) :

core@coreos:~$ podman logs fedora
level=debug msg="Running as real user ID 0"
level=debug msg="Resolved absolute path to the executable as /usr/bin/toolbox"
level=debug msg="TOOLBOX_PATH is /usr/bin/toolbox"
level=debug msg="Migrating to newer Podman"
level=debug msg="Migration not needed: running inside a container"
level=debug msg="Setting up configuration"
level=debug msg="Setting up configuration: file /etc/containers/toolbox.conf not found"
level=debug msg="Setting up configuration: file /root/.config/containers/toolbox.conf not found"
level=debug msg="Resolving container and image names"
level=debug msg="Container: ''"
level=debug msg="Distribution (CLI): ''"
level=debug msg="Image (CLI): ''"
level=debug msg="Release (CLI): ''"
level=debug msg="Resolved container and image names"
level=debug msg="Container: 'fedora-toolbox-39'"
level=debug msg="Image: 'fedora-toolbox:39'"
level=debug msg="Release: '39'"
level=debug msg="Creating /run/.toolboxenv"
level=debug msg="Path /run/host/etc exists"
level=debug msg="Preparing to redirect /etc/host.conf to /run/host/etc/host.conf"
level=debug msg="/run/host/etc/host.conf isn't a symbolic link"
level=debug msg="Redirecting /etc/host.conf to /run/host/etc/host.conf"
level=debug msg="Preparing to redirect /etc/hosts to /run/host/etc/hosts"
level=debug msg="/run/host/etc/hosts isn't a symbolic link"
level=debug msg="Redirecting /etc/hosts to /run/host/etc/hosts"
level=debug msg="Preparing to redirect /etc/localtime to /run/host/etc/localtime"
level=debug msg="/run/host/etc/localtime is a symbolic link"
level=debug msg="Redirecting /etc/localtime to /run/host/etc/localtime"
level=debug msg="Resolved /etc/localtime to /run/host/usr/share/zoneinfo/Indian/Mauritius"
level=debug msg="Preparing to redirect /etc/resolv.conf to /run/host/etc/resolv.conf"
level=debug msg="/run/host/etc/resolv.conf is a symbolic link"
level=debug msg="Redirecting /etc/resolv.conf to /run/host/etc/resolv.conf"
level=debug msg="Preparing to redirect /media to /run/media"
level=debug msg="/run/media isn't a symbolic link"
level=debug msg="Redirecting /media to /run/media"
level=debug msg="Preparing to redirect /mnt to /var/mnt"
level=warning msg="/var/mnt not found"
level=debug msg="Redirecting /mnt to /var/mnt"
level=debug msg="Creating regular file /etc/machine-id"
level=debug msg="Binding /etc/machine-id to /run/host/etc/machine-id"
level=debug msg="Creating directory /run/systemd/journal"
level=debug msg="Binding /run/systemd/journal to /run/host/run/systemd/journal"
level=debug msg="Creating directory /run/systemd/resolve"
level=debug msg="Binding /run/systemd/resolve to /run/host/run/systemd/resolve"
level=debug msg="Creating directory /run/systemd/sessions"
level=debug msg="Binding /run/systemd/sessions to /run/host/run/systemd/sessions"
level=debug msg="Creating directory /run/systemd/system"
level=debug msg="Binding /run/systemd/system to /run/host/run/systemd/system"
level=debug msg="Creating directory /run/systemd/users"
level=debug msg="Binding /run/systemd/users to /run/host/run/systemd/users"
level=debug msg="Creating directory /run/udev/data"
level=debug msg="Binding /run/udev/data to /run/host/run/udev/data"
level=debug msg="Creating directory /run/udev/tags"
level=debug msg="Binding /run/udev/tags to /run/host/run/udev/tags"
level=debug msg="Creating directory /tmp"
level=debug msg="Binding /tmp to /run/host/tmp"
level=debug msg="Creating directory /var/lib/systemd/coredump"
level=debug msg="Binding /var/lib/systemd/coredump to /run/host/var/lib/systemd/coredump"
level=debug msg="Creating directory /var/log/journal"
level=debug msg="Binding /var/log/journal to /run/host/var/log/journal"
level=debug msg="Creating directory /var/mnt"
level=debug msg="Binding /var/mnt to /run/host/var/mnt"
level=debug msg="Creating directory /sys/fs/selinux"
level=debug msg="Binding /sys/fs/selinux to /usr/share/empty"
level=debug msg="Preparing to redirect /home to /var/home"
level=debug msg="/var/home isn't a symbolic link"
level=debug msg="Redirecting /home to /var/home"
level=debug msg="Looking up group for sudo"
level=debug msg="Group for sudo is wheel"
level=debug msg="Modifying user core with UID 1000:"
level=debug msg=usermod
level=debug msg=--append
level=debug msg=--groups
level=debug msg=wheel
level=debug msg=--home
level=debug msg=/var/home/core
level=debug msg=--password
level=debug
level=debug msg=--shell
level=debug msg=/bin/bash
level=debug msg=--uid
level=debug msg=1000
level=debug msg=core
level=debug msg="Removing password for user root"
Error: failed to remove password for root: passwd(1) not found
level=debug msg="Running as real user ID 0"
level=debug msg="Resolved absolute path to the executable as /usr/bin/toolbox"
level=debug msg="TOOLBOX_PATH is /usr/bin/toolbox"
level=debug msg="Migrating to newer Podman"
level=debug msg="Migration not needed: running inside a container"
level=debug msg="Setting up configuration"
level=debug msg="Setting up configuration: file /etc/containers/toolbox.conf not found"
level=debug msg="Setting up configuration: file /root/.config/containers/toolbox.conf not found"
level=debug msg="Resolving container and image names"
level=debug msg="Container: ''"
level=debug msg="Distribution (CLI): ''"
level=debug msg="Image (CLI): ''"
level=debug msg="Release (CLI): ''"
level=debug msg="Resolved container and image names"
level=debug msg="Container: 'fedora-toolbox-39'"
level=debug msg="Image: 'fedora-toolbox:39'"
level=debug msg="Release: '39'"
level=debug msg="Creating /run/.toolboxenv"
level=debug msg="Path /run/host/etc exists"
level=debug msg="Resolved /etc/localtime to /run/host/usr/share/zoneinfo/Indian/Mauritius"
level=debug msg="Creating regular file /etc/machine-id"
level=debug msg="Binding /etc/machine-id to /run/host/etc/machine-id"
level=debug msg="Creating directory /run/systemd/journal"
level=debug msg="Binding /run/systemd/journal to /run/host/run/systemd/journal"
level=debug msg="Creating directory /run/systemd/resolve"
level=debug msg="Binding /run/systemd/resolve to /run/host/run/systemd/resolve"
level=debug msg="Creating directory /run/systemd/sessions"
level=debug msg="Binding /run/systemd/sessions to /run/host/run/systemd/sessions"
level=debug msg="Creating directory /run/systemd/system"
level=debug msg="Binding /run/systemd/system to /run/host/run/systemd/system"
level=debug msg="Creating directory /run/systemd/users"
level=debug msg="Binding /run/systemd/users to /run/host/run/systemd/users"
level=debug msg="Creating directory /run/udev/data"
level=debug msg="Binding /run/udev/data to /run/host/run/udev/data"
level=debug msg="Creating directory /run/udev/tags"
level=debug msg="Binding /run/udev/tags to /run/host/run/udev/tags"
level=debug msg="Creating directory /tmp"
level=debug msg="Binding /tmp to /run/host/tmp"
level=debug msg="Creating directory /var/lib/systemd/coredump"
level=debug msg="Binding /var/lib/systemd/coredump to /run/host/var/lib/systemd/coredump"
level=debug msg="Creating directory /var/log/journal"
level=debug msg="Binding /var/log/journal to /run/host/var/log/journal"
level=debug msg="Creating directory /var/mnt"
level=debug msg="Binding /var/mnt to /run/host/var/mnt"
level=debug msg="Creating directory /sys/fs/selinux"
level=debug msg="Binding /sys/fs/selinux to /usr/share/empty"
level=debug msg="Preparing to redirect /home to /var/home"
level=debug msg="/var/home isn't a symbolic link"
level=debug msg="Redirecting /home to /var/home"
level=debug msg="Looking up group for sudo"
level=debug msg="Group for sudo is wheel"
level=debug msg="Modifying user core with UID 1000:"
level=debug msg=usermod
level=debug msg=--append
level=debug msg=--groups
level=debug msg=wheel
level=debug msg=--home
level=debug msg=/var/home/core
level=debug msg=--password
level=debug
level=debug msg=--shell
level=debug msg=/bin/bash
level=debug msg=--uid
level=debug msg=1000
level=debug msg=core
level=debug msg="Removing password for user root"
Error: failed to remove password for root: passwd(1) not found

Toolbox with --log-devel debug says (Error: invalid entry point PID of container fedora):

core@coreos:~$ toolbox enter fedora --log-level debug
DEBU Running as real user ID 1000
DEBU Resolved absolute path to the executable as /usr/bin/toolbox
DEBU Running on a cgroups v2 host
DEBU Looking for sub-GID and sub-UID ranges for user core
DEBU TOOLBOX_PATH is /usr/bin/toolbox
DEBU Migrating to newer Podman
DEBU Toolbox config directory is /var/home/core/.config/toolbox
DEBU Current Podman version is 4.7.2
DEBU Creating runtime directory /run/user/1000/toolbox
DEBU Old Podman version is 4.7.2
DEBU Migration not needed: Podman version 4.7.2 is unchanged
DEBU Setting up configuration
DEBU Setting up configuration: file /var/home/core/.config/containers/toolbox.conf not found
DEBU Resolving container and image names
DEBU Container: ''
DEBU Distribution (CLI): ''
DEBU Image (CLI): ''
DEBU Release (CLI): ''
DEBU Resolved container and image names
DEBU Container: 'fedora-toolbox-39'
DEBU Image: 'fedora-toolbox:39'
DEBU Release: '39'
DEBU Resolving container and image names
DEBU Container: 'fedora'
DEBU Distribution (CLI): ''
DEBU Image (CLI): ''
DEBU Release (CLI): ''
DEBU Resolved container and image names
DEBU Container: 'fedora'
DEBU Image: 'fedora-toolbox:39'
DEBU Release: '39'
DEBU Checking if container fedora exists
DEBU Inspecting mounts of container fedora
DEBU Starting container fedora
DEBU Inspecting entry point of container fedora
DEBU Entry point PID is a float64
DEBU Entry point of container fedora is toolbox (PID=0)
Error: invalid entry point PID of container fedora

The output of podman start --attach:

core@coreos:~$ podman start --attach fedora
level=debug msg="Running as real user ID 0"
level=debug msg="Resolved absolute path to the executable as /usr/bin/toolbox"
level=debug msg="TOOLBOX_PATH is /usr/bin/toolbox"
level=debug msg="Migrating to newer Podman"
level=debug msg="Migration not needed: running inside a container"
level=debug msg="Setting up configuration"
level=debug msg="Setting up configuration: file /etc/containers/toolbox.conf not found"
level=debug msg="Setting up configuration: file /root/.config/containers/toolbox.conf not found"
level=debug msg="Resolving container and image names"
level=debug msg="Container: ''"
level=debug msg="Distribution (CLI): ''"
level=debug msg="Image (CLI): ''"
level=debug msg="Release (CLI): ''"
level=debug msg="Resolved container and image names"
level=debug msg="Container: 'fedora-toolbox-39'"
level=debug msg="Image: 'fedora-toolbox:39'"
level=debug msg="Release: '39'"
level=debug msg="Creating /run/.toolboxenv"
level=debug msg="Path /run/host/etc exists"
level=debug msg="Resolved /etc/localtime to /run/host/usr/share/zoneinfo/Indian/Mauritius"
level=debug msg="Creating regular file /etc/machine-id"
level=debug msg="Binding /etc/machine-id to /run/host/etc/machine-id"
level=debug msg="Creating directory /run/systemd/journal"
level=debug msg="Binding /run/systemd/journal to /run/host/run/systemd/journal"
level=debug msg="Creating directory /run/systemd/resolve"
level=debug msg="Binding /run/systemd/resolve to /run/host/run/systemd/resolve"
level=debug msg="Creating directory /run/systemd/sessions"
level=debug msg="Binding /run/systemd/sessions to /run/host/run/systemd/sessions"
level=debug msg="Creating directory /run/systemd/system"
level=debug msg="Binding /run/systemd/system to /run/host/run/systemd/system"
level=debug msg="Creating directory /run/systemd/users"
level=debug msg="Binding /run/systemd/users to /run/host/run/systemd/users"
level=debug msg="Creating directory /run/udev/data"
level=debug msg="Binding /run/udev/data to /run/host/run/udev/data"
level=debug msg="Creating directory /run/udev/tags"
level=debug msg="Binding /run/udev/tags to /run/host/run/udev/tags"
level=debug msg="Creating directory /tmp"
level=debug msg="Binding /tmp to /run/host/tmp"
level=debug msg="Creating directory /var/lib/systemd/coredump"
level=debug msg="Binding /var/lib/systemd/coredump to /run/host/var/lib/systemd/coredump"
level=debug msg="Creating directory /var/log/journal"
level=debug msg="Binding /var/log/journal to /run/host/var/log/journal"
level=debug msg="Creating directory /var/mnt"
level=debug msg="Binding /var/mnt to /run/host/var/mnt"
level=debug msg="Creating directory /sys/fs/selinux"
level=debug msg="Binding /sys/fs/selinux to /usr/share/empty"
level=debug msg="Preparing to redirect /home to /var/home"
level=debug msg="/var/home isn't a symbolic link"
level=debug msg="Redirecting /home to /var/home"
level=debug msg="Looking up group for sudo"
level=debug msg="Group for sudo is wheel"
level=debug msg="Modifying user core with UID 1000:"
level=debug msg=usermod
level=debug msg=--append
level=debug msg=--groups
level=debug msg=wheel
level=debug msg=--home
level=debug msg=/var/home/core
level=debug msg=--password
level=debug
level=debug msg=--shell
level=debug msg=/bin/bash
level=debug msg=--uid
level=debug msg=1000
level=debug msg=core
level=debug msg="Removing password for user root"
Error: failed to remove password for root: passwd(1) not found

Steps how to reproduce the behaviour

  1. Create toolbox containter with: toolbox create --image registry.fedoraproject.org/fedora:39 fedora
  2. Enter the container: toolbox enter fedora

Expected behaviour Get a shell inside the container

Toolbox Version

core@coreos:~$ toolbox --version
toolbox version 0.0.99.4

Toolbox package info (rpm -q toolbox)

core@coreos:~$ rpm -q toolbox
toolbox-0.0.99.4-5.fc39.x86_64

Output of podman version

Client:       Podman Engine
Version:      4.7.2
API Version:  4.7.2
Go Version:   go1.21.1
Built:        Tue Oct 31 18:32:01 2023
OS/Arch:      linux/amd64

Podman package info (rpm -q podman)

core@coreos:~$ rpm -q podman
podman-4.7.2-1.fc39.x86_64

Info about your OS

core@coreos:~$ cat /etc/os-release
NAME="Fedora Linux"
VERSION="39.20231119.3.0 (CoreOS)"
ID=fedora
VERSION_ID=39
VERSION_CODENAME=""
PLATFORM_ID="platform:f39"
PRETTY_NAME="Fedora CoreOS 39.20231119.3.0"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:39"
HOME_URL="https://getfedora.org/coreos/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora-coreos/"
SUPPORT_URL="https://github.com/coreos/fedora-coreos-tracker/"
BUG_REPORT_URL="https://github.com/coreos/fedora-coreos-tracker/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=39
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=39
SUPPORT_END=2024-05-14
VARIANT="CoreOS"
VARIANT_ID=coreos
OSTREE_VERSION='39.20231119.3.0'
debarshiray commented 5 months ago

level=debug msg="Removing password for user root" Error: failed to remove password for root: passwd(1) not found

It's failing because the container doesn't have passwd(1).

Create toolbox containter with: toolbox create --image registry.fedoraproject.org/fedora:39 fedora

This isn't supported, because registry.fedoraproject.org/fedora:39 isn't a Toolbx image, which means that in this case passwd(1) is missing from it.

We should probably at least add a warning when users try to use non-Toolbx images.

Is there any reason you didn't want to use the default registry.fedoraproject.org/fedora-toolbox images for Fedora?

kavishgr commented 5 months ago

Is there any reason you didn't want to use the default registry.fedoraproject.org/fedora-toolbox images for Fedora?

How did I miss this! It should have been a toolbox image. There was a bug on Google Cloud. It was configured to fetch a base Fedora image instead of the toolbox in /etc/default/toolbox. Sorry for wasting your time.

debarshiray commented 5 months ago

Is there any reason you didn't want to use the default registry.fedoraproject.org/fedora-toolbox images for Fedora?

How did I miss this! It should have been a toolbox image. There was a bug on Google Cloud. It was configured to fetch a base Fedora image instead of the toolbox in /etc/default/toolbox. Sorry for wasting your time.

I see, cool. Thanks for stopping by.