当前位置: 首页 > news >正文

Docker入门指南:Linux系统下的完整安装步骤与常见问题解答

本文以centos7演示。

Docker安装

可参考官方安装文档:Install Docker Engine on CentOS | Docker Docs

一图流:

# 移除旧版本docker
sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine# 配置docker yum源。
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo# 安装 最新 docker
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin# 启动 & 开机启动docker; enable + start 二合一
systemctl enable docker --now# 配置加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

具体操作

0)移除旧版本Docker

sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine

1)配置docker yum源(安装工具类,配置地址源)

sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  • 官网(备用,不太推荐):
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  • 如果此步在安装过程中如下图报错:
[root@localhost ~]# sudo yum install -y yum-utils
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"One of the configured repositories failed (未知),and yum doesn't have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few ways to work "fix" this:1. Contact the upstream for the repository and get them to fix the problem.2. Reconfigure the baseurl/etc. for the repository, to point to a workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-manager repos --disable=<repoid>5. Configure the failing repository to be skipped, if it is unavailable.Note that yum will try to contact the repo. when it runs most commands,so will have to try and fail each time (and thus. yum will be be muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=trueCannot find a valid baseurl for repo: base/7/x86_64
  • 更换yum源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

  • 安装wget

yum install -y wget

  • 下载CentOS 7的对应的repo文件

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

参考资料:

  • centos镜像_centos下载地址_centos安装教程-阿里巴巴开源镜像站 (aliyun.com)
  • CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org; Name or service not known“之解决办法(换源)_could not resolve host: mirrorlist.centos.org; nam-CSDN博客
  • yum无法使用解决方法(比较全,以后如果遇到别的问题还会添加) - 王章章章 - 博客园 (cnblogs.com)

3)安装 最新 docker

sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

4)启动& 开机启动docker(enable + start 二合一)

systemctl enable docker --now

5)配置加速

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
http://www.lryc.cn/news/407825.html

相关文章:

  • Netty实现数据上下行
  • 【React】事件绑定:深入解析高效处理用户交互的最佳实践
  • SpringCloud:使用OpenFeign优化前面的Nacos实现高效购物车商品信息处理
  • 计算机三级嵌入式笔记(二)——嵌入式处理器
  • 【GoLang】Golang 快速入门(第一篇)
  • Linux中的三类读写函数
  • MATLAB基础应用精讲-【数模应用】二元Probit回归分析
  • 找工作准备刷题Day10 回溯算法 (卡尔41期训练营 7.24)
  • 如何有效的进行小程序的优化
  • FPGA-ROM IP核的使用(2)
  • Manticore Search(es轻量级替代)
  • 测试开发面试题---计算机网络
  • Wonder3D 论文学习
  • 【MySQL进阶之路 | 高级篇】显式事务和隐式事务
  • Ruby、Python、Java 开发者必备:Codigger之软件项目体检
  • day05 Router、vuex、axios
  • yolov5-7在opencv里跑自己的onnx模型
  • JVM 11 的优化指南:如何进行JVM调优,JVM调优参数有哪些
  • nginx的配置和使用
  • mysql面试(六)
  • 6.乳腺癌良性恶性预测(二分类、逻辑回归、PCA降维、SVD奇异值分解)
  • Vue3响应式高阶用法之markRaw()
  • 免费SSL证书的安全性与获取指南
  • 【CN】Argo 持续集成和交付(一)
  • Unity3D 自定义Debug双击溯源问题详解
  • 环境搭建-Docker搭建ClickHouse
  • 深入理解CSS中的变量(概念篇)
  • Prometheus 监控Tomcat等java应用的状态
  • c++中的斐波那契数列(Fibonacci Sequence)和背包问题(Knapsack Problem)
  • connect的非阻塞模式