jesseduffield / lazydocker

The lazier way to manage everything docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Pull bitnami/openldap image with docker pull bitnami/openldap
  2. Launch it (docker run --rm bitnami/openldap)
  3. Launch lazydocker
  4. 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)

  1. Pull quay.io/keycloak/keycloak:18.0 image with docker pull quay.io/keycloak/keycloak:18.0
  2. Launch it (docker run --rm quay.io/keycloak/keycloak:18.0 start-dev)
  3. Launch lazydocker
  4. 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.

ezoic increase your site revenue