Reputation: 4949
I'm trying to do an interactive session with a specific username and password.
docker run -it --rm --user 616:605 -e USER=penny \
-v /Y/penny/resource:/penny/
e5542f8d0cf8 bash
the command above results in a prompt
I have no name!@2bed4cfb594g:/$
What I want is to have the username with the group gid correctly login so that I can read/write files with the correct permissions.
thanks!
Upvotes: 0
Views: 3778
Reputation: 3760
Apparently, the /etc/passwd file in your container has no entry for the username for the UID:GID 616:605.
If you run the id command inside your container, you will get the UID. Now copy the /etc/passwd file from your container and add the name to the UID.
# copy file to the host file system at /tmp
docker cp e5542f8d0cf8:/etc/passwd /tmp
# Append (not overwrite) to the file
echo "username:x:616:605:username:/tmp:/bin/bash" >> /tmp/passwd
# copy the file from the host to the container
docker cp /tmp/passwd e5542f8d0cf8:/etc/passwd
Now login to the container again and you should see the username
Upvotes: 1