Reputation: 71
Mounted the .ssh folder into a docker container.
permissions on the host (ls -laHF
):
total 40K
drwxr-xr-x 2 git git 4.0K Apr 7 21:27 ./
drwxr-xr-x 3 git git 4.0K Apr 7 21:20 ../
-rw------- 1 git git 2.7K Apr 7 21:27 authorized_keys
-rw------- 1 git git 2.6K Dec 11 15:34 authorized_keys_1675190689.gitea_bak
-rw------- 1 git git 25 Dec 11 14:02 environment
-rw------- 1 git git 411 Apr 7 21:25 id_ed25519
-rw-r--r-- 1 git git 96 Apr 7 21:25 id_ed25519.pub
-rw------- 1 git git 3.4K Dec 11 14:16 id_rsa
-rw-r--r-- 1 git git 740 Dec 11 14:16 id_rsa.pub
-rw-r--r-- 1 git git 222 Dec 11 14:24 known_hosts
when i go to the mount in the container and do the same the owner changed:
total 40K
drwxr-xr-x 2 nobody nobody 4.0K Apr 7 21:27 ./
drwxr-xr-x 5 git git 4.0K Dec 11 14:09 ../
-rw------- 1 nobody nobody 2.6K Apr 7 21:27 authorized_keys
-rw------- 1 nobody nobody 2.5K Dec 11 15:34 authorized_keys_1675190689.gitea_bak
-rw------- 1 nobody nobody 25 Dec 11 14:02 environment
-rw------- 1 nobody nobody 411 Apr 7 21:25 id_ed25519
-rw-r--r-- 1 nobody nobody 96 Apr 7 21:25 id_ed25519.pub
-rw------- 1 nobody nobody 3.3K Dec 11 14:16 id_rsa
-rw-r--r-- 1 nobody nobody 740 Dec 11 14:16 id_rsa.pub
-rw-r--r-- 1 nobody nobody 222 Dec 11 14:24 known_hosts
the volumes are mounted with
services:
server:
volumes:
- /home/git/.ssh:/data/git/.ssh
Does anyone have any idea how that can be possible?
i have tried mounting the same folder into another container with
docker run -it -v /home/git/.ssh:/data/git/.ssh ubuntu:latest
This time all files are owned by nobody:nogroup
(before it was nobody:nobody
),
so the problem is not with the service inside the container
Upvotes: 5
Views: 2275
Reputation: 71
Found out my user (in this case git
) wasn't in the docker
group.
The group can be added with sudo usermod -aG docker git
Upvotes: 0
Reputation: 629
Every docker image will have a Dockerfile in Github check is that have USER instruction line, which is not exactly the user you have on your host machine. To get the hostmachine UID, GID and then use them to create containers we can [specify the 'user'][1] attribute as :
image: alpine
user: "${UID}:${GID}"
[1]: https://blog.giovannidemizio.eu/2021/05/24/how-to-set-user-and-group-in-docker-compose/
Upvotes: -1