赞
踩
目录
ps:安装不成功则需要安装container-selinux,下载网络yum源,再安装docker-ce即可
学习docker需要学习到docker镜像、docker容器、docker仓库。
docker安装官方文档:Install Docker Engine on CentOS
- [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
[root@localhost ~]# yum -y install 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
- [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
[root@docker-learn yum.repos.d]# systemctl start docker
如下主要是registry-mirrors有所改变
#查看Registry Mirrors
[root@docker-learn docker]# docker info
- [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
- [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/

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。