docker简介

(1)Docker是管理容器的引擎,为应用打包、部署平台,而非单纯的虚拟化技术。

(2)传统虚拟化与容器技术对比

虚拟机 docker容器
操作系统 宿主机上运行虚拟机OS 共享宿主机OS
存储 镜像较大(GB) 镜像小(MB)
性能 操作系统额外的cpu、内存消耗 几乎无性能损耗
移植性 笨重、与虚拟化技术耦合度高 轻量、灵活迁移
隔离性 完全隔离 安全隔离
部署 慢、分钟级 快速、秒级
运行密度 一般几十个 单机支持上千容器

 

 

 

 

 

 

 

 

 

 

 

docker容器的优势:

(1)对于开发人员:Build once、Run anywhere

(2)对于运维人员:Configure once、Run anything

开发重代码,运维重配置

容器技术大大提升了IT人员的幸福指数!

Docker的安装

docker官方站点下载比较慢,我这里使用的是阿里云的站点下载速度相对来说会快一点

官方站点:  https://docs.docker.com/

速度虽然比较慢,但还是不影响参考官方文档的,有兴趣可以看看

阿里云开源镜像站:  https://mirrors.aliyun.com/

(1) 把阿里云的软件仓库下载到本地

进入阿里云镜像站===>容器===>docker-ce===>找到阿里云docker软件仓库源地址下载下来


cd /etc/yum.repos.d/      ##一定要下载到/etc/yum.repos.d/才会生效
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
ls
docker-ce.repo  node.repo
vim /etc/yum.repos.d/docker-ce.repo    ##对其中的源进行更改,如下
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=0

yum repolist                          ##查看下载编辑后的源有无问题

(2)解决依赖性

现在直接下载的话会报错,所以要先解决依赖性的问题

他所需要的依赖性全部都在centos源里面,所以我们直接把centos源地址下载下来

进入阿里云镜像站===>centos===>找到阿里云centos软件仓库源地址下载下来


wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

vim CentOS-Base.repo                 ##修改源中的内容,只留下我们需要的,如下
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

#[base]
#name=CentOS-$releasever - Base - mirrors.aliyun.com
#failovermethod=priority
#baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
#gpgcheck=0

#released updates
#[updates]
#name=CentOS-$releasever - Updates - mirrors.aliyun.com
#failovermethod=priority
#baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
#gpgcheck=0

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
gpgcheck=0

 (3)下载 docker-ce


 yum install docker-ce -y

 (4)启动docker


systemctl start docker
systemctl enable docker

(5)导入景象,运行容器


docker load -i game2048     ##导入镜像game2048
docker run -d --name game1 -p 80:80 game2048   ##在80端口运行容器game2048

然后就可以进入docker的海洋, 仰泳,蛙泳,蝶泳了(我喜欢的方式是狗刨)。。。。。


云野 » Docker-容器简介及安装

发表回复