centos7安装docker(包含yum配置阿里云镜像源)

yum配置阿里云镜像源

1.备份源repo文件

cd /etc/yum.repos.d
mkdir bak
mv *.repo bak/

2.获取阿里云镜像源文件

cd /etc/yum.repos.d
wget http://mirrors.aliyun.com/repo/Centos-7.repo
如果wget命令不存在,执行yum install wget,重新执行以上命令。
也可以使用浏览器访问http://mirrors.aliyun.com/repo/Centos-7.repo网址手动下载,然后上传至服务器的/etc/yum.repos.d目录下。

3.使用镜像文件

yum clean all
yum makecache

docker安装

1.卸载旧版本docker

sudo yum remove docker \
docker-common \
docker-selinux \
docker-engine

2.安装依赖包

sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2

3.鉴于国内网络问题,强烈建议使用国内源

sudo yum-config-manager \
--add-repo \
https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo

4.安装docker

sudo yum-config-manager --enable docker-ce-edge
yum makecache fast
sudo yum install docker-ce

5.配置国内镜像源

vi /etc/docker/daemon.json 

如果/etc/docker/daemon.json不存在,手动创建,将以下内容写入文件中。

{
"registry-mirrors": ["https://registry.docker-cn.com"]
}

6.启动docker

sudo systemctl enable docker
sudo systemctl start docker

7.检查是否安装成功

docker run hello-world

如果打印如下信息,便安装成功。

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Status: Downloaded newer image for hello-world:latest
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://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值