环境
Ubutnu 22.04 LTS + AMD64
安装1
使用系统软件仓库中的软件包
1
| sudo apt install docker.io
|
安装2
使用docker官方软件源
1 2 3 4 5 6 7 8 9
| sudo apt install curl gnupg lsb-release apt-transport-https curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io sudo systemctl start docker sudo systemctl status docker sudo systemctl enable docker sudo docker --version
|
用户权限
默认情况下,docker命令需要sudo权限,将docker添加到sudo列表中
1 2 3
| sudo groupadd docker sudo usermod -aG docker hyper newgrp docker
|
软件源
使用国内软件源提供加速
1 2 3 4 5 6 7 8 9 10
| sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://tdcar6xs.mirror.aliyuncs.com"] } EOF
sudo systemctl daemon-reload sudo systemctl restart docker
|
命令
常用命令
1 2 3 4 5 6 7 8 9 10
| docker search pkg docker pull pkg docker ps docker run pkg docker rm c docker rmi i docker exec cmd docker build docker images docker start/stop/pause/restart/kill
|