Last active
November 2, 2022 22:48
-
-
Save MnifR/3b0799667e172e21985dc30e72a640a1 to your computer and use it in GitHub Desktop.
docker’s userns-remap feature allows us to use a default dockremap user. In this scenario, docker engine creates the user dockremap on the host and maps the root user inside a container to this user. For this user, docker also needs to have entries on the host’s /etc/subuid and /etc/subgid files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################### | |
# Docker userns-remap and system users on Linux | |
############################################################### | |
groupadd -g 500000 dockremap && | |
groupadd -g 501000 dockremap-user && | |
useradd -u 500000 -g dockremap -s /bin/false dockremap && | |
useradd -u 501000 -g dockremap-user -s /bin/false dockremap-user | |
echo "dockremap:500000:65536" >> /etc/subuid && | |
echo "dockremap:500000:65536" >>/etc/subgid | |
echo " | |
{ | |
\"userns-remap\": \"default\" | |
} | |
" > /etc/docker/daemon.json | |
systemctl daemon-reload && systemctl restart docker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment