cancel
Showing results for 
Search instead for 
Did you mean: 
jonawang
Flight Engineer
Flight Engineer
  • 9,330 Views

/bin/bash NOT FOUND under container when run "podman exec -it <container_name> /bin/bash"

Jump to solution

Hi podman experts,

   After a container is created using "podman run -d --name <container_name> ...", I encountered a problem as described in the subject title --  "podman exec -it <container_name> /bin/bash"  shows /bin/bash not found. Detailed message as the following:

jonawang_0-1656831639298.png

When using /bin/sh to run inside container and listing /bin/bash shows : No such file.

jonawang_2-1656831852221.png

Under RHEL 8 Linux, /bin/bash does exist as shown in the following screenshot.

jonawang_1-1656831753641.png

I retried the above scenario both on Podman v3 and on Podman v4, the result is the same on most of my Linux VMs (RHEL 8 and CentOS 8).

 

  Can anyone advise me how to resolve this problem ? Thanks

 

Best regard,

 

Labels (3)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Fran_Garcia
Starfighter Starfighter
Starfighter
  • 9,270 Views

That seems to be an image based on AlpineLinux :

$ podman run --rm -it quay.io/libpod/banner sh
/ # hostname
6092007ed534

/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.16.0
PRETTY_NAME="Alpine Linux v3.16"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

/ # apk add bash
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ncurses-terminfo-base (6.3_p20220521-r0)
(2/4) Installing ncurses-libs (6.3_p20220521-r0)
(3/4) Installing readline (8.1.2-r0)
(4/4) Installing bash (5.1.16-r2)
Executing bash-5.1.16-r2.post-install
Executing busybox-1.35.0-r13.trigger
OK: 12 MiB in 25 packages

/ # bash
bash-5.1#
exit
/ #

 

View solution in original post

5 Replies
Ravi_Shanker
Flight Engineer
Flight Engineer
  • 9,323 Views

What is the image you are using for this podman command ? It is quite possible you are using a hardened image which doesn't have the shells enabled. You could also try podman cp bash or sh to the containers /bin/ and then the exec command should possibly work.

Certification ID: 111-010-393
0 Kudos
jonawang
Flight Engineer
Flight Engineer
  • 9,299 Views

The image is quay.io/libpod/banner which is built from busybox. It sounds like busybox does not support /bin/bash. Even I used "podman cp" command coping the /bin/bash to the container built from this image, it still didn't work.

I used the "quay.io/redhattraining/httpd-parent" image to do the same scenario test, it worked as expected.

So thanks for your guidance. I thought "podman exec ..." command should be able to support usual Linux command like bash but it depends.

Ravi_Shanker
Flight Engineer
Flight Engineer
  • 9,292 Views

Someone with more knowledge can explain better on on how this image quay.io/libpod/banner would have been built or why the bash command fails even after doing podman cp.

ravi@EX180:podman run -d --name=banner quay.io/libpod/banner
f3af42f36e0b309f230949632b97991ebccb91590cffb4f35cf4ae37b98a6751
ravi@EX180:podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f3af42f36e0b quay.io/libpod/banner:latest nginx -g daemon o... 8 seconds ago Up 8 seconds ago banner
ravi@EX180:podman exec -it banner /bin/bash
Error: crun: executable file `/bin/bash` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found
ravi@EX180:podman exec -it banner /bin/sh
/ # pwd
/
/ # hostname
f3af42f36e0b
/ #
ravi@EX180:podman cp /bin/bash banner:/bin/
ravi@EX180:podman exec -it banner /bin/bash
exec: No such file or directory
ravi@EX180:podman exec -it banner /bin/sh
/ # cd /bin
/bin # ls -la
total 2180
drwxr-xr-x 1 root root 18 Jul 3 15:25 .
dr-xr-xr-x 1 root root 62 Jul 3 15:24 ..
lrwxrwxrwx 1 root root 12 May 23 16:51 arch -> /bin/busybox
lrwxrwxrwx 1 root root 12 May 23 16:51 ash -> /bin/busybox
lrwxrwxrwx 1 root root 12 May 23 16:51 base64 -> /bin/busybox
-rwxr-xr-x 1 root root 1390168 Nov 5 2021 bash
lrwxrwxrwx 1 root root 12 May 23 16:51 bbconfig -> /bin/busybox
-rwxr-xr-x 1 root root 837272 May 9 17:27 busybox

Certification ID: 111-010-393
Fran_Garcia
Starfighter Starfighter
Starfighter
  • 9,271 Views

That seems to be an image based on AlpineLinux :

$ podman run --rm -it quay.io/libpod/banner sh
/ # hostname
6092007ed534

/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.16.0
PRETTY_NAME="Alpine Linux v3.16"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

/ # apk add bash
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ncurses-terminfo-base (6.3_p20220521-r0)
(2/4) Installing ncurses-libs (6.3_p20220521-r0)
(3/4) Installing readline (8.1.2-r0)
(4/4) Installing bash (5.1.16-r2)
Executing bash-5.1.16-r2.post-install
Executing busybox-1.35.0-r13.trigger
OK: 12 MiB in 25 packages

/ # bash
bash-5.1#
exit
/ #

 

Marek_Czernek
Flight Engineer Flight Engineer
Flight Engineer
  • 9,177 Views

Note that you should not install packages in a running container. Either create a new container with the package baked in, or, in this case, I'd recommend using sh instead of bash (unless there's some specific reason for bash)

Join the discussion
You must log in to join this conversation.