sysconfig/docker-allow-user.sh
2023-09-09 14:50:46 +08:00

18 lines
397 B
Bash
Executable File

echo "=== Add a non-root user to run docker"
if [ "$1" ]
then
DOCKERUSER=$1
else
echo "Enter the <user name> or <leave blank> for default to '`whoami`'"
read -p ">>> " DOCKERUSER
if [ ! "$DOCKERUSER" ]
then
DOCKERUSER=`whoami`
fi
fi
sudo usermod -aG docker $DOCKERUSER
sudo systemctl restart docker
groups $DOCKERUSER
newgrp docker # run as the docker group in the current shell