"I have no name!" as user logging into Jenkins in a docker container that uses Tini
update
good to know (this was to easy, so I overlooked this for some time *facepalm*):
To login into a container as root, just give --user root
to your exec command - like:
docker exec -ti -u root mycontainername bash
... no need to copy passwd file and set pw-hashes ...
Like your posted link says, the UserID inside the container maybe has no name allocated.
(Although I do not use Tini... ) I solved this problem as following:
1.) execute INSIDE the container (docker exec -ti mycontainername sh
):
id # shows the userid (e.g. 1234) and groupid (e.g. 1235) of the current session
2.) execute OUTSIDE the container (on the local machine):
docker cp mycontainername:/etc/passwd /tmp # this copies the passwd-file to from inside the container to my local /tmp-directoryecho "somename:x:1234:1235:somename:/tmp:/bin/bash" >> /tmp/passwd # add some username *!!with the userid and groupid from the output!!* of the `id` command inside the container (CAUTION: do NOT overwrite, do JUST APPEND to the file) - "1234" is just exemplary, do not use itdocker cp /tmp/passwd mycontainername:/etc/passwd # copy the file back, overwriting the /etc/passwd inside the container
Now login to the container (docker exec -ti mycontainername sh
) again.
P.S.If you know the root password of the container you can now switch to rootIf you don't have it, you can copy the "/etc/shadow" file out of the container (like above), then edit the root-entry with a known password hash**, then copy it back into the container and then login to the container and run su
)
** to get this password hash on your local system:(1) add a temporary testuser (sudo useradd testdumpuser
)(2) give this user as password (sudo passwd testdumpuser
)(3) look in the /etc/shadow
-file for the "testdumpuser"-entry and copy this long odd string after the first ":" until the second ":"