Docker安装
Ubuntu22.04
安装====
apt-get update
apt-get install ca-certificates curl gnupg lsb-release #必要软件
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg #安装证书
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io #安装Docker
docker version #成功后弹出版本号等信息
卸载====
apt-get remove docker docker-engine docker.io containerd runc #移除旧版本
rm -rf /var/lib/docker
rm -rf /var/lib/containerd
操作====
docker pull [image]:[TAG] #拉取对应版本镜像,不填TAG默认:[latest]
docker images #查看所有镜像
docker ps -a #查看所有容器服务
docker rmi (-f) [image]:[TAG] #(强制)删除对应镜像
docker rm (-f) [container] #(强制)删除容器服务
设置代理
mkdir -p /etc/systemd/system/docker.service.d
vim /etc/systemd/system/docker.service.d/http-proxy.conf
# 写入下面的内容,代理需要自己搭建
[Service]
Environment="HTTP_PROXY=socks5://192.168.1.5:1089/"
Environment="HTTPS_PROXY=socks5://192.168.1.5:1089/"
Environment="NO_PROXY=localhost,127.0.0.1"
# 重启
systemctl daemon-reload
systemctl restart docker
# 测试,输出列表即为成功
docker search hellow
Docker 镜像拉取过慢
方案1:在 windows11 上安装 docker-desktop 程序,前提是开启虚拟化服务。docker-desktop 的实质就是安装了两个虚拟机,wsl 的操作都适用,可以迁移虚拟机等
在 windows 上运行 clash 代理拉取镜像,然后就可以很快拉取镜像,然后推送到私人仓库
注: 配置 setting->docker engine添加配置使 docker 可以用 http 推送 "insecure-registries": ["www.youcats.cn:5000"],重启 docker 即可
方案2:使用上面的代理
配置文件
daemon.json
{
"experimental": true,
"ip6tables": true,
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64",
"insecure-registries": ["192.168.1.5:5000","www.youcats.cn:5000"],
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://mirror.ccs.tencentyun.com",
"https://214wkok4.mirror.aliyuncs.com"
],
"live-restore": false,
"log-driver": "json-file",
"log-opts": {
"max-size": "500m",
"max-file": "3"
}
}
CentOS7
yum -y install gcc
yum -y install gcc-c++
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
docker -v
卸载====
yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-selinux
docker-engine-selinux
docker-engine
docker-ce
docker-compose
下载对应的包
https://github.com/docker/compose/releases/download/v2.24.0/docker-compose-linux-aarch64
移动到
/usr/local/bin
添加可执行权限
chmod +x /usr/local/bin/docker-compose
docker-compose -v
评论