sudo systemctl stop apparmor.service
sudo systemctl disable apparmor.service
sudo ufw disable
# Uninstall all conflicting packages.
sudo apt remove -y docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc
# Set up Docker's repository.
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
# Install the Docker packages.
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Add user to the docker group
sudo usermod -G docker -a $USER
# And re-login
# 阿巴阿巴
sudo mkdir -p /opt/var/lib/docker/
sudo chmod 710 /opt/var/lib/docker/
sudo touch /etc/docker/daemon.json
sudo vi /etc/docker/daemon.json
{
"data-root": "/opt/var/lib/docker"
}
sudo ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose
sudo systemctl restart docker.service
sudo systemctl restart containerd.service
# Verify that the Docker Engine installation is successful.
docker run hello-world