shell/install/docker
2024-12-02 16:12:18 +08:00

40 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
##makedesc: Install docker (latest) + ppa
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://docs.docker.com/engine/install/ubuntu/
# https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
title
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do
apt_remove $pkg
done
require ca-certificates lsb-release
source /etc/os-release
key="/etc/apt/keyrings/docker.asc"
sudo install -m 0755 -d /etc/apt/keyrings
sudo cdownload https://download.docker.com/linux/ubuntu/gpg $key
sudo chmod a+r $key
echo "deb [arch=$(dpkg_arch) signed-by=$key] https://download.docker.com/linux/ubuntu $VERSION_CODENAME stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt_update
apt_install \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
sudo usermod -aG docker $(whoami)
newgrp docker
success "Docker installed!"
docker --version
info "Probably, you need to relogin to apply 'docker' group permanently."