文章目录
- 一、docker安装
- 二、centos7 安装docker-compose
- 三、修改docker的镜像源
- 四、docker异常处理(没有那个文件或目录)
- 五、配置虚拟机上docker的代理
- 总结
一、docker安装
# 安装上传下载工具 上传命令rz -bey,下载命令sz 文件名
yum -y install lrzsz
# 更改centos源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 删除旧docker(可选)
yum -y remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
# 安装依赖库
yum -y install yum-utils
# 删除yum缓存和重建缓存(可选)
yum clean all
yum makecache
#安装一些必备工具 (可选)
yum -y install java-11-openjdk-headless java-11-openjdk java-11-openjdk-devel
# 安装docker必备工具
yum -y install net-tools wget vim python3 keyutils unzip lvm2
#安装docker 国外
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 安装docker 阿里云
#yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装docker-compose-plugin插件
yum -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# 启动docker并设置开机启动
systemctl start docker
systemctl enable docker
二、centos7 安装docker-compose
# 指定下载docker-compose版本 2.x或者1.x curl -L "https://github.com/docker/compose/releases/download/2.17.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# 修改docker-compose权限
chmod +x /usr/local/bin/docker-compose
三、修改docker的镜像源
mkdir -p /etc/docker
mkdir -p /root/b/docker
cat >/etc/docker/daemon.conf <<-'EOF'
{
"registry-mirrors": [
"https://vuc60d52.mirror.aliyuncs.com",
"https://vmlwbfhf.mirror.aliyuncs.com",
"http://f1361db2.m.daocloud.io",
"https://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.baidubce.com",
"https://ustc-edu-cn.mirror.aliyuncs.com",
"https://registry.cn-hangzhou.aliyuncs.com",
"https://ccr.ccs.tencentyun.com",
"https://hub.daocloud.io",
"https://docker.shootchat.top",
"https://do.nark.eu.org",
"https://dockerproxy.com",
"https://docker.m.daocloud.io",
"https://dockerhub.timeweb.cloud",
"https://docker.shootchat.top",
"https://do.nark.eu.org
],
"data-root": "/var/lib/docker",
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true",
"overlay2.size=20G"
]
}
EOF
# 重启docker
systemctl daemon-reload
systemctl restart docker
四、docker异常处理(没有那个文件或目录)
- 如果docker-compose的出现异常,显示如下
- 直接在release中下载对应的linux发行版【docker-compose-linux-x86_64】
https://github.com/docker/compose/releases/tag/v2.18.1
下载完后将软件上传至 Linux的【/usr/local/bin】目录下
# 重命名
sudo mv docker-compose-linux-x86_64 docker-compose
#将可执行权限应用于二进制文件:`
sudo chmod +x /usr/local/bin/docker-compose`
# 创建软链:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
五、配置虚拟机上docker的代理
- 确认宿主机windows的防火墙已经打开
- 虚拟机配置如下(设置为宿主机的ip和端口号)
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<"EOF"
[Service]
Environment="HTTP_PROXY=http://192.168.0.106:7890/"
Environment="HTTPS_PROXY=http://192.168.0.106:7890/"
Environment="ALL_PROXY=http://192.168.0.106:7890"
Environment="NO_PROXY=localhost,127.0.0.1"
EOF
systemctl daemon-reload
systemctl restart docker
总结
本文介绍了docker的下载,如有问题欢迎私信和评论