3
$ docker run --rm -it busybox
/ # who
<empty>

In the next session I'm trying to attach to this docker container and expecting second user will appear, but no luck again:

$ docker attach `docker container ls | grep busybox | cut -d" " -f1`
/ # who
<empty again>

So the question is - why there are no logons happened not by first run-and-attach, not by consequent attaches? And why there is no even a single logon into this container?

Alex Martian
  • 3,423
  • 7
  • 36
  • 71
egor7
  • 4,678
  • 7
  • 31
  • 55
  • Is it so for specific container only - busybox? – Alex Martian Aug 16 '19 at 06:39
  • I mentioned busybox only for example, this situation keeps on Ubuntu images too. You can try: `docker run --rm -it ubuntu:18.10` then type `who` – egor7 Aug 16 '19 at 08:47
  • The answer of Alexander now seems more to the point than, if you run docker on Linux, but that answer is not marked as accepted yet, so... Are you on Linux? Do you think the reason could be OS specific? – Alex Martian Aug 16 '19 at 09:24

2 Answers2

4

who reads the list of users from /var/run/utmp. On a regular Linux system, the login program prompts for the username and password and then starts the user's shell. It also updates /var/run/utmp with the new user. The same thing happens for SSH and Telnet servers. They are expected to update /var/run/utmp.

In a Docker container, login is usually not executed. Docker isolates resources from the host system with Linux Namespaces, it does not provide a complete Linux system. When you enter a Docker container, the given entrypoint or command is executed with PID 1. Subsequent docker exec calls are handled in a similar way. Docker enters the namespace of the container and executes the given command.

3

EDIT: after some reading I see Alexander answer as more to the point. Couple of useful links I've read along that way:

https://docs.docker.com/engine/security/security/

https://lwn.net/Articles/531114


As far as I understand busybox docker container is very basic and does not support all functionality of full-fledged Linux.

Here I thought I understood Docker until I saw the BusyBox docker image there is a discussion about what that image is and what it is for.

Alex Martian
  • 3,423
  • 7
  • 36
  • 71