Docker安装/Centos7
Long Long Ago: 其实直接参考官方文档即可:docs.docker.com/engine/inst…
Centos是否符合条件
查看Centos版本号
Docker-Centos安装需求:==7或8==
[root@VM_0_8_centos ~]# uname -a
Linux VM_0_8_centos 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
#Linux 内核名称
#VM_0_8_centos 网络节点主机名称
#3.10.0-154.21.1.el7.x86_64 内核Release
# 内核Release详解
# 主版本号 3
# 次版本号 10[奇数表示开发版 偶数表示稳定版]
# 修订号 0 [修订次数]
# 此次版本第N次修改:154
# el7: RedHat Enterprise Linux 7
# x86_64 编译框架
#
##1 SMP Thu May 25 17:04:51 UTC 2017 内核版本
#x86_64 机器名称
#x86_64 处理器名称
#x86_64 硬件平台名称
#GNU/Linux 操作系统名称
卸载旧版本Docker
[root@VM_0_8_centos ~]# yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Packages marked for removal
安装软件包
#安装yum-utils(提供yum-config-manager实用程序)
[root@VM_0_8_centos ~]# yum install -y yum-utils
设置存储库
#设置稳定存储库(官方)
[root@VM_0_8_centos ~]# yum-config-manager
--add-repo
https://download.docker.com/linux/centos/docker-ce.repo
#阿里云国内镜像
[root@VM_0_8_centos ~]# yum-config-manager
--add-repo
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装Docker 引擎
# docker-ce 社区版 docker-ee
[root@VM_0_8_centos ~]# yum install docker-ce docker-ce-cli containerd.io
启动Docker
[root@VM_0_8_centos ~]# systemctl start docker
启动测试用例
[root@VM_0_8_centos ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec
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://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
查看镜像
[root@VM_0_8_centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 12 months ago 13.3kB
卸载Docker
[root@VM_0_8_centos ~]yum remove docker-ce docker-ce-cli containerd.io
[root@VM_0_8_centos ~]rm -rf /var/lib/docker
#/var/lib/docker Docker 默认工作路径
其他参考文档:
1.Ubuntu国内镜像源安装Docker-Engine juejin.cn/post/713573…