当前位置:   article > 正文

yum安装Docker(CentOS7.9)_yum install docker

yum install docker

目录

          一、安装环境

编写yum源(根据系统版本)

二、安装docker-ce

默认安装docker-ce是最新版本

ps:安装不成功则需要安装container-selinux,下载网络yum源,再安装docker-ce即可

#查看dcoker-ce所产生的文件路径

三、启动docker

四、配置镜像加速器

第一种:docker cn 加速

第二种:中国科技大学

其他:阿里云,DaoCloud需要申请账号获得个人链接。

#运行一个比较简单的容器


学习docker需要学习到docker镜像、docker容器、docker仓库。

docker安装官方文档:Install Docker Engine on CentOS

一、安装环境

编写yum源(根据系统版本)

  1. [root@docker-learn yum.repos.d]# vim aliyun.repo
  2. [base]
  3. name=base
  4. baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/x86_64/
  5. gpgcheck=0
  6. [root@docker-learn yum.repos.d]# vim docker-ce.repo
  7. [docker-ce]
  8. name=docker
  9. baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.9/x86_64/stable/
  10. gpgcheck=0
  1. #缓存
  2. [root@docker-learn yum.repos.d]# yum makecache fast
  3. #查看有哪些缓存
  4. [root@docker-learn yum.repos.d]# yum repolist
  5. 清除缓存
  6. [root@docker-learn yum.repos.d]# yum clearn all

二、安装docker-ce

默认安装docker-ce是最新版本

​[root@localhost ~]# yum -y install docker-ce 安装的是默认最新版本

ps:安装不成功则需要安装container-selinux,下载网络yum源,再安装docker-ce即可

  1. [root@localhost yum.repos.d]# wget -0 /etc/yum.repos.d/Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  2. #注:安装docker-ce需要container-selinux,以下仓库提供该包以及它的依赖包,如下是在官网
  3. [root@server ~]# vim /etc/yum.repos.d/centos-extras.repo
  4. [root@server ~]# cat /etc/yum.repos.d/centos-extras.repo
  5. [centos-extras]
  6. name=centos
  7. baseurl=http://mirror.centos.org/centos/7/extras/x86_64/
  8. enabled=1
  9. gpgcheck=0

接着再安装docker-ce

#查看dcoker-ce所产生的文件路径

  1. [root@docker-learn yum.repos.d]# rpm -ql docker-ce
  2. /etc/docker
  3. /usr/bin/docker-init
  4. /usr/bin/docker-proxy
  5. /usr/bin/dockerd
  6. /usr/lib/systemd/system/docker.service
  7. /usr/lib/systemd/system/docker.socket

三、启动docker

[root@docker-learn yum.repos.d]# systemctl start docker

四、配置镜像加速器

如下主要是registry-mirrors有所改变

#查看Registry Mirrors

[root@docker-learn docker]# docker info

第一种:docker cn 加速

  1. [root@docker-learn docker]# vim daemon.json
  2. {
  3. "registry-mirrors":["https://registry.docker-cn.com"]
  4. }
  5. [root@docker-learn docker]# systemctl daemon-reload
  6. [root@docker-learn docker]# systemctl restart docker

第二种:中国科技大学

  1. [root@docker-learn docker]# vim daemon.json
  2. {
  3. "registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
  4. }

#如果docker run报iptables disable的warning可进行开启

  1. [root@docker-learn docker]# vim /etc/sysctl.conf
  2. net.bridge.bridge-nf.call-iptables = 1
  3. net.bridge.bridge-nf.call-ip6tables = 1
  4. [root@docker-learn etc]# sysctl -p

其他:阿里云,DaoCloud需要申请账号获得个人链接。

#运行一个比较简单的容器

  1. [root@docker-learn docker]# docker run hello-world
  2. Hello from Docker!
  3. This message shows that your installation appears to be working correctly.
  4. To generate this message, Docker took the following steps:
  5. 1. The Docker client contacted the Docker daemon.
  6. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
  7.     (amd64)
  8. 3. The Docker daemon created a new container from that image which runs the
  9.     executable that produces the output you are currently reading.
  10. 4. The Docker daemon streamed that output to the Docker client, which sent it
  11.     to your terminal.
  12. To try something more ambitious, you can run an Ubuntu container with:
  13. $ docker run -it ubuntu bash
  14. Share images, automate workflows, and more with a free Docker ID:
  15. https://hub.docker.com/
  16. For more examples and ideas, visit:
  17. https://docs.docker.com/get-started/

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号