Shell is not executed for some containers
jtraub opened this issue · comments
Describe the bug
Shell is not executed for some containers
To Reproduce
Steps to reproduce the behavior:
- Pull
bitnami/openldap
image withdocker pull bitnami/openldap
- Launch it (
docker run --rm bitnami/openldap
) - Launch lazydocker
- Select running openldap container and press
E
to get into container shell
Expected behaviour
You are dropped into container shell.
Actual behaviour
I see id: cannot find name for user ID 1001
message.
This happens because image maintainer used USER 1001
command in the Dockerfile to set custom uid for the image. Obviously this user id is not present in /etc/passwd
file - hence lazydocker command fails to detect shell.
I think lazydocker should try to detect preferred shell and if it fails to find one or execute one /bin/sh
should be launched instead.
This approach will solve another shell-related problem (steps to reproduce below)
- Pull
quay.io/keycloak/keycloak:18.0
image withdocker pull quay.io/keycloak/keycloak:18.0
- Launch it (
docker run --rm quay.io/keycloak/keycloak:18.0 start-dev
) - Launch lazydocker
- Try to drop into shell by pressing
E
against keycloak container
You will see an error because Red Hat developers put /sbin/nologin
(/bin/false
seems to be another popular option in such cases though) as the shell for image user to tighten security. However, you still can directly exec /bin/sh
and get access to the shell.
Also I should mention that I have an image without grep in it which also makes exec shell
command to fail. Yes, it is a very specific image and I have custom command which simply execs /bin/sh
against container but I would really like to see some bulletproof solution implemented in lazydocker.