CentOS7下如何正确安装并启动Docker(图文详解)
我使用了CentOS 7操作系统,可以非常容易地安装Docker环境。假设,下面我们都是用root用户进行操作,执行如下命令进行准备工作:
yum install -y yum-utils
yum-config-manager \
--add-repo \ https://docs.docker.com/engine/installation/linux/repo_files/centos/docker.repo yum makecache fast
上面首先安装了yum-utils,它提供了yum-config-manager管理工具,然后安装了最新稳定版本的Repository文件,最后更新yum的package索引。
执行如下命令:
sudo yum -y install docker-engine
首次安装docker-engine,输出类似如下日志信息:
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:1.13.1-1.el7.centos will be installed
--> Processing Dependency: docker-engine-selinux >= 1.13.1-1.el7.centos for package: docker-engine-1.13.1-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-engine-selinux.noarch 0:1.13.1-1.el7.centos will be installed
--> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
docker-engine x86_64 1.13.1-1.el7.centos docker-main 19 M
Installing for dependencies:
docker-engine-selinux noarch 1.13.1-1.el7.centos docker-main 28 k Transaction Summary
=================================================================================================================================================================================================================
Install 1 Package (+1 Dependent package) Total download size: 19 M
Installed size: 65 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/docker-main/packages/docker-engine-selinux-1.13.1-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY ] 1.2 MB/s | 944 kB 00:00:14 ETA
Public key for docker-engine-selinux-1.13.1-1.el7.centos.noarch.rpm is not installed
(1/2): docker-engine-selinux-1.13.1-1.el7.centos.noarch.rpm | 28 kB 00:00:01
(2/2): docker-engine-1.13.1-1.el7.centos.x86_64.rpm | 19 MB 00:00:04
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.5 MB/s | 19 MB 00:00:04
Retrieving key from https://yum.dockerproject.org/gpg
Importing GPG key 0x2C52609D:
Userid : "Docker Release Tool (releasedocker) <docker@docker.com>"
Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d
From : https://yum.dockerproject.org/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-engine-selinux-1.13.1-1.el7.centos.noarch 1/2
libsemanage.semanage_direct_install_info: Overriding docker module at lower priority 100 with module at priority 400.
restorecon: lstat(/var/lib/docker) failed: No such file or directory
warning: %post(docker-engine-selinux-1.13.1-1.el7.centos.noarch) scriptlet failed, exit status 255
Non-fatal POSTIN scriptlet failure in rpm package docker-engine-selinux-1.13.1-1.el7.centos.noarch
Installing : docker-engine-1.13.1-1.el7.centos.x86_64 2/2
Verifying : docker-engine-selinux-1.13.1-1.el7.centos.noarch 1/2
Verifying : docker-engine-1.13.1-1.el7.centos.x86_64 2/2 Installed:
docker-engine.x86_64 0:1.13.1-1.el7.centos Dependency Installed:
docker-engine-selinux.noarch 0:1.13.1-1.el7.centos Complete!
可见,Docker已经成功安装。
下面,我们就可以启动Docker了,执行如下命令,启动Docker(Docker Engine):
systemctl start docker
可以查看一下当前系统上的进程,执行ps -ef | grep docker确认Docker已经启动:
root 2717 1 8 21:52 ? 00:00:00 /usr/bin/dockerd
root 2723 2717 1 21:52 ? 00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root 2920 2645 0 21:52 pts/0 00:00:00 grep --color=auto docker
下面,我们验证一下,Docker启动了,应该就可以在一个Container中运行一个准备好的应用,执行如下命令:
docker run hello-world
基于一个名称为hello-world的Image,启动Container并运行它,启动过程如下所示:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
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.
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
首先可以看到,因为本地没有下载过该Image,所以会先从Docker Hub上下载,对应的tag是latest。另外,也可以看到提示信息“Hello from Docker! ”,表示我们的环境配置没问题,可以启动Container运行应用程序。这里,还给出了运行我们这个名称为hello-world的示例Image在Container中运行过程中。
Docker的基本运行机制如下所示:
- Docker Client连接到Docker daemon
- Docker daemon从Docker Hub上下载名称为hello-world的Image
- Docker daemon基于这个Image创建了一个新的Container,并运行应用程序,输出“Hello from Docker!”
- Docker daemon将结果输出到Docker Client,也就是我们的终端上
现在,我们可能想知道hello-world这个Image是如何构建,才能够最终在我们的Docker Container中运行,请看下文。
CentOS7下如何正确安装并启动Docker(图文详解)的更多相关文章
- Windows 7操作系统下Apache的安装与配置(图文详解)
我这里是 Apache2.4.X-win64 首先, 我的操作系统信息如下 Apache2.4-win64的下载 官网 http://www.apachelounge.com/download/ 因 ...
- VirtualBox里如何正确安装增强工具(图文详解)
不多说,直接上干货! 找到 复制到
- Windows 7操作系统下PHP 7的安装与配置(图文详解)
前提博客 Windows 7操作系统下Apache的安装与配置(图文详解) 从官网下载 PHP的官网 http://www.php.net/ 特意,新建这么一个目录 ...
- CentOS 6.3下Samba服务器的安装与配置方法(图文详解)
这篇文章主要介绍了CentOS 6.3下Samba服务器的安装与配置方法(图文详解),需要的朋友可以参考下 一.简介 Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件, ...
- Ubuntu14.04下Mongodb官网安装部署步骤(图文详解)(博主推荐)
不多说,直接上干货! 在这篇博客里,我采用了非官网的安装步骤,来进行安装.走了弯路,同时,也是不建议.因为在大数据领域和实际生产里,还是要走正规的为好. Ubuntu14.04下Mongodb(离线安 ...
- Ubuntu16.04下Mongodb官网安装部署步骤(图文详解)(博主推荐)
不多说,直接上干货! 在这篇博客里,我采用了非官网的安装步骤,来进行安装.走了弯路,同时,也是不建议.因为在大数据领域和实际生产里,还是要走正规的为好. Ubuntu16.04下Mongodb(离线安 ...
- Ubuntu14.04下Mongodb(离线安装方式|非apt-get)安装部署步骤(图文详解)(博主推荐)
不多说,直接上干货! 说在前面的话 首先,查看下你的操作系统的版本. root@zhouls-virtual-machine:~# cat /etc/issue Ubuntu LTS \n \l r ...
- Ubuntu16.04下Mongodb(离线安装方式|非apt-get)安装部署步骤(图文详解)(博主推荐)
不多说,直接上干货! 说在前面的话 首先,查看下你的操作系统的版本. root@zhouls-virtual-machine:~# cat /etc/issue Ubuntu LTS \n \l r ...
- Ubuntu14.04下Mongodb数据库可视化工具安装部署步骤(图文详解)(博主推荐)
不多说,直接上干货! 前期博客 Ubuntu14.04下Mongodb(离线安装方式|非apt-get)安装部署步骤(图文详解)(博主推荐) Ubuntu14.04下Mongodb官网安装部署步骤(图 ...
随机推荐
- iOS--判断字符串NSString中数字、中文、大小写英文
iOS--判断字符串NSString中数字.中文.大小写英文 <iframe id="iframeu2051914_0" src="http://pos.bai ...
- 高仿美团iOS版,版本5.7
高仿美团iOS版,版本:5.7 iOS技术交流群:112365317 github链接:https://github.com/lookingstars/meituan 假设你认为不错.欢迎star 哦 ...
- winfrom桌面程序调用python解释器
Winfrom桌面程序调用python解释器执行py脚本后台执行完成具体的功能,为什么要这样处理呢?因为我现在的大部分过项目都是后台的脚本处理,界面基本的输入完成之后,将参数按照规则传入到脚本的入口, ...
- MapReduce算法形式六:只有Map独自作战
案例六:Map独自直接输出 之前一直没有用过这个map独自输出的模式,就算是输出一些简单的我也会经过一次reduce输出,但是,发现这个map输出的结果跟我预想的有点不一样,我一直以为shuffle的 ...
- Qt & opencv 学习(一)
Qt也没怎么系统学过,opencv也没系统学过.慢慢来,一步一步弄清楚吧. 天嵌科技有个文档,先去看这个文档,主要是开发环境的配置.文档名字就是QT应用程序开发手册-20150918.pdf.在QT里 ...
- [翻译]Unity中的AssetBundle详解(三)
构建AssetBundles 在AssetBundle工作流程的文档中,我们有一个示例代码,它将三个参数传递给BuildPipeline.BuildAssetBundles函数.让我们更深入地了解我们 ...
- Windows 7 繁体中文MSDN原版
Win7 SP1 64位旗舰版繁体版ISO镜像(香港):文件名:hk_windows_7_enterprise_with_sp1_x64_dvd_620688.isoSHA1:82D59B099333 ...
- 一步一步学Silverlight 2系列(17):数据与通信之ADO.NET Data Services
概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...
- SPOJ:Eagle and Dogs(求树上每个点最远可以走到哪里---树的直径||DP)
Eagle (AKA Mohamed Ahmed) lives in a city consists of n intersections connected by n-1 roads, in a w ...
- Ordered Fractions
链接 分析:遍历一下,求个gcd即可,最后按照ans排序并去重 /* PROB:frac1 ID:wanghan LANG:C++ */ #include "iostream" # ...