
Docker 帮助系统管理员和程序员在容器中开发应用程序,并且可以扩展到成千上万的节点,容器和 VM(虚拟机)的主要区别是,容器提供了基于进程的隔离,而虚拟机提供了资源的完全隔离。虚拟机可能需要一分钟来启动,而容器只需要一秒钟或更短,容器使用宿主操作系统的内核,而虚拟机使用独立的内核,Docker 的局限性之一是,它只能用在 64 位的操作系统上。
虚拟机与Docker有何不同?https://www.techug.com/post/comparing-virtual-machines-vs-docker-containers.html
Docker的组成:
- Docker Client 客户端
- Docker Daemon 守护进程
- Docker Image 镜像
- Docker Container 容器
看到一个形象的比喻,截图摘自:https://www.cnblogs.com/qgc1995/p/9553572.html

Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。
通过uname -r
命令查看你当前的内核版本:

Docker 软件包已经包括在默认的 CentOS-Extras 软件源里。因此想要安装 docker,只需运行命令:
[root@centos7 ~]# yum install docker

查看docker版本:
[root@centos7 ~]# docker version

发现了一个问题:
问题截图
如上所示错误,具体解决办法:
systemctl daemon-reload systemctl restart docker
再次查看docker 版本,出现如下图所示,则正常:

安装完成后,使用下面的命令来启动 docker 服务,并将其设置为开机启动:
[root@centos7 ~]# systemctl start docker.service
[root@centos7 ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
拉取官方的 CentOS 镜像到本地:
[root@centos7 ~]# docker pull centos

再次输入docker images
,查看镜像是否拉取成功:

启动centos镜像:docker命令 -i 捕获标准输入输出
和 -t 分配一个终端或控制台
[root@centos7 ~]# docker run -i -t centos /bin/bash
[root@eb79f5aac269 /]#
若要断开与容器的连接,则输入 exit
。
[root@eb79f5aac269 /]# exit
exit
测试docker是否正常安装和运行:
[root@centos7 ~]# docker run hello-world

查看所有创建的容器docker ps -a

网友评论