#linux #docker #homelab Normal Docker Installation
- Download installer script:
curl -fsSL get.docker.com -o get-docker.sh - Execute the script:
sh get-docker.sh - Add user to docker group:
sudo groupadd docker
sudo gpasswd -a <user-name> docker - Reboot
To update Docker rerun the get-docker.sh script.
Enabling Docker in Rootless Mode
To run Docker in rootless mode, follow the steps outlined below:- Install dbus-user-session, uidmap packages
- If accessing via SSH, install systemd-container to switch to the local user:
sudo apt install systemd-container
sudo machinectl shell TheUser@<hostname>
- Create a non-root user and add it to the docker group User-Management (sudo usermod -aG docker)
- Download and execute rootless docker:
curl -fsSL https://get.docker.com/rootless | sh
- Follow the instructions of script
- Next, in order to allow you to publish containers using ports <1024, you need to add the following line to /etc/sysctl.conf
# Change the port number to what ever port should be the lowest port bindable for non root users.
net.ipv4.ip_unprivileged_port_start=80
Save the file and then reload the sysctl settings: sudo sysctl -p
Uninstall Docker
- Remove packages:
sudo apt-get purge docker-ce docker-ce-cli containerd.io - Remove all Docker data (images, containers, volumes):
sudo rm -rf /var/lib/docker
General
To enable Docker to start automatically on login and to keep it running after logout:systemctl --user start docker
systemctl --user enable docker
# Allow for docker to run in the background
sudo loginctl enable-linger $(whoami)