- 一、Docker 安装
- 卸载Docker CE
- 卸载Docker EE
- 删除Docker镜像、容器、数据卷等文件
- 官方源
- https://download.docker.com/linux/ubuntu/gpg | sudo gpg —dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg">curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg —dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- 下载镜像
- 启动
- 打上私有仓库的标签
- 推送
- 五、Docker 相关命令
- 参考
一、Docker 安装
1.1、Windown 下安装
https://docs.docker.com/toolbox/toolbox_install_windows/
1.2、linux 下安装
https://docs.docker.com/engine/install/ubuntu/
手动安装
卸载旧版本 ```shell sudo apt-get remove docker docker-engine docker.io containerd runc
完全卸载
卸载Docker CE
sudo apt-get purge docker-ce
卸载Docker EE
sudo apt-get purge docker-ee
删除Docker镜像、容器、数据卷等文件
sudo rm -rf /var/lib/docker
- 添加使用 HTTPS 传输的软件包以及 CA 证书。
```shell
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
- 添加软件源的 GPG 密钥。 ```shell curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg —dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
官方源
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg —dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- 添加docker 源到/etc/apt/source.list中
```shell
$ echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 官方源
# $ echo \
# "deb [arch=amd64 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-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
脚本安装
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
1.3、Docker 配置
开机启动
$ sudo systemctl enable docker
$ sudo systemctl start docker
建立 docker 用户组
#查看用户组
groups
#创建用户组
sudo groupadd docker
#将当前用户添加到docker 用户组
sudo usermod -aG docker $USER
#重启
reboot
配置加速
/etc/docker/daemon.json 中写入如下内容
registry-mirrors: 镜像源
data-root: 镜像数据位置
"insecure-registries" : ["106.13.17.252:5000"]
"data-root": "/home/ec2-user/software/docker-data"
"mtu": 1450,
"dns": ["192.10.0.2", "8.8.8.8"]
{
"registry-mirrors": [
"https://mirror.ccs.tencentyun.com",
"https://dockerhub.azk8s.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com",
"https://reg-mirror.qiniu.com",
"https://hub-mirror.c.163.com",
"https://hub.daocloud.io"
]
}
重启服务
sudo systemctl daemon-reload
sudo systemctl restart docker
二、Docker-compose安装
三、Docker-swam安装
四、私有仓库安装
4.1 官方私有仓库
下载Registry的Docker镜像
docker pull registry:2
启动
docker run -p 5000:5000 --name registry2 \
--restart=always \
-e REGISTRY_STORAGE_DELETE_ENABLED="true" \
-d registry:2
修改Docker Daemon的配置文件,改为使用HTTP推送
#/etc/docker/daemon.json
{
"insecure-registries": ["192.168.3.101:5000"]
}
重启docker
systemctl daemon-reload && systemctl restart docker
镜像仓库可视化
```下载镜像
docker pull joxit/docker-registry-ui:static
启动
docker run -p 8280:80 —name registry-ui \ —link registry2:registry2 \ -e REGISTRY_URL=”http://registry2:5000“ \ -e DELETE_IMAGES=”true” \ -e REGISTRY_TITLE=”Registry2” \ -d joxit/docker-registry-ui:static
打上私有仓库的标签
docker tag busybox 192.168.3.101:5000/busybox:v1.0
推送
docker push 192.168.3.101:5000/busybox:v1.0 ```