yum安装Docker(CentOS7.9)

目录

          一、安装环境

编写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源(根据系统版本)

[root@docker-learn yum.repos.d]# vim aliyun.repo
[base]
name=base
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/x86_64/
gpgcheck=0
​
[root@docker-learn yum.repos.d]# vim docker-ce.repo
[docker-ce]
name=docker
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7.9/x86_64/stable/
gpgcheck=0
#缓存
[root@docker-learn yum.repos.d]# yum makecache fast

#查看有哪些缓存
[root@docker-learn yum.repos.d]# yum repolist

清除缓存
[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即可

[root@localhost yum.repos.d]# wget -0 /etc/yum.repos.d/Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#注:安装docker-ce需要container-selinux,以下仓库提供该包以及它的依赖包,如下是在官网

[root@server ~]# vim /etc/yum.repos.d/centos-extras.repo
[root@server ~]# cat /etc/yum.repos.d/centos-extras.repo
[centos-extras]
name=centos
baseurl=http://mirror.centos.org/centos/7/extras/x86_64/
enabled=1
gpgcheck=0

接着再安装docker-ce

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

[root@docker-learn yum.repos.d]# rpm -ql docker-ce
/etc/docker
/usr/bin/docker-init
/usr/bin/docker-proxy
/usr/bin/dockerd
/usr/lib/systemd/system/docker.service
/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 加速

[root@docker-learn docker]# vim daemon.json
{
"registry-mirrors":["https://registry.docker-cn.com"]
}

[root@docker-learn docker]# systemctl daemon-reload
[root@docker-learn docker]# systemctl restart docker

第二种:中国科技大学

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

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

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

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

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

[root@docker-learn docker]# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值