Docker安装
跟新于 2024-02-14
ubuntu下安装
测试系统
- Ubuntu Groovy 22.04 (LTS)
卸载系统自带docker
| Bash |
|---|
| sudo apt remove docker docker-engine docker.io containerd runc
|
安装Docker
离线安装
- 查看系统ubuntu版本
lsb_release -cs
- 访问docker安装包仓库
- 选择对应得
ubuntu版本
- 点击
pool ,stable
- 根据CPU型号选择版本
amd64,armhf, or arm64
- 下载指定版本得deb包并安装
- 拷贝到设备上,
- 执行
dpdk -i *.deb安装
在线安装
现在仓库基本都用https,需要添加对应的GPG密钥
安装基础软件
| Bash |
|---|
| sudo apt update
sudo apt install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common`
|
添加GPG密钥
官方密钥
| Bash |
|---|
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
得到密钥,其指纹为9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
验证指纹
| Bash |
|---|
| sudo apt-key fingerprint 0EBFCD88
|
阿里镜像密钥
| Bash |
|---|
| curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
|
清华镜像密钥
| Bash |
|---|
| curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
|
添加软件仓库地址
官方仓库
| Bash |
|---|
| sudo add-apt-repository "deb [arch=amd64]https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
阿里镜像站仓库
| Bash |
|---|
| sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
|
清华镜像站仓库
| Bash |
|---|
| sudo add-apt-repository "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
|
安装
| Bash |
|---|
| sudo apt-get update
#安装最新版
sudo apt-get install docker-ce docker-ce-cli containerd.io
|
安装特殊版本
- a.列出可选版本
| Bash |
|---|
| sudo apt-cache madison docker-ce
|
将会看到
| Text Only |
|---|
| docker-ce | 5:18.09.1~3-0~ubuntu-xenial |https://download.docker.com/linux/ubuntuxenial/stable amd64 Packages<br>
docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages<br>
docker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages<br>
docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages<br>
|
- b.安装指定版本
| Bash |
|---|
| sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
|
检测
| Bash |
|---|
| #查看版本号
sudo docker --verison
|
卸载
| Bash |
|---|
| sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
|
设置权限
docker 命令默认需要 root 用户权限才能运行
如果你想让一个普通用户能够运行 docker 命令
| Bash |
|---|
| # 创建docker组
sudo groupadd docker
# 将用户加入docker组
sudo usermod -aG docker user-name
# 退出重新登陆
# 或 激活用户组更改
newgrp docker
|