jesseduffield / jesseduffield/lazydocker

Shell is not executed for some containers

Open
#350 0 comments 3 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
52.8k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

**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](https://github.com/bitnami/bitnami-docker-openldap/blob/master/2.6/debian-10/Dockerfile#L26) 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.