DOCKER 01: specifications and installation

About dcoker

 

 

Before writing a number of reasons for this part, but the feeling is not comprehensive, so I plan to be a complete re-organize, you may say.

Now in 2020, as the operation and maintenance personnel around slowly, but the sill is a container arrangement of this content. Compared to the traditional operation and maintenance, container transport above-dimensional development prospects and salary is still very substantial. This is also the purpose of learning and the power of the technology.

 

About the history docker, we need to know in advance simply the following:

1. docker is dotcloud company (founded in 2010, in 2013 changed its name to Docker Co., Ltd.) open source project on GitHub above.

2. Since 2015 runC release, docker embarked on a truly cross-platform, which is also the origin of a core idea of ​​the docker: build once run everywhere.

3.2016 onwards, docker split became Community Edition docker CE and commercial Docker EE , we have a docker CE.

4. docker after the 1.13 version, change the nomenclature for the year. Months of ways, such as 18.06, the monthly release cutting-edge version (Edge) and three released stable version (Stable).

5. docker called in the old version of CentOS source docker, Ubuntu source called docker.io, now called the unified Docker-ce .

6. docker storage engine experienced by the devicemapper and then to overlay on CentOS in overlay2 advanced, performance and Ubuntu has been able to AUFS par. 

 

About concepts docker, we need to know in advance simply the following:

1. docker by the Go language development, typical of the C / S architecture.

2. docker container technology into a peak, but the technology did not arise in the container docker.

3. docker belong Container Linux ( LXC , kernel comes with a kernel virtualization technology that provides lightweight processes and resource isolation) of the upper package, so the technology is not new.

4. docker container technology is not the best practice, but because of great reputation, wide use, is still the main goal of learning.

5. learning docker not the ultimate goal, is to prepare for learning choreography container tool Kubernetes.

6. docker has its own scheduling tool docker swarm, but the reasons do not win because the dry kubernetes has stopped fast maintenance.

7. docker is a Paas service concept of Pass, Saas services such as illustrated in Figure 17, the red part of the user management section requires:

As for the other content, at the time I wrote back to say!

 

 

The advantages and disadvantages of docker

 

The Internet can be seen everywhere is the official document of the above can be seen everywhere on a docker and VM compare Figure:

You can obviously find:

VM traditional working process:

1. First, you need a server, installation is similar to VMware workstation on top of such software, but is generally used on such servers are VMware esxi.

2. Then on top of this software management interface new virtual machine, install the operating system, such as IP configuration.

3. Finally, install the service you want to run in this new virtual machine above.

 

Container work process:

1. server to install the system, either Linux can also be a Windows, and install the docker.

2. Run the service container that we want to run, and above each container there is a system to host a separate process.

 

Both do comparison can be found:

1. 传统的 VM 每次新增虚拟机就需要重装系统,并单独运行系统,这样会导致 CPU,内存,磁盘的额外开销。但是好处在于隔离效果比较好。

2. 使用容器则不需安装额外的操作系统,每个服务都以进程的方式跑在宿主机上,且拥有独立的虚拟网络环境,独立的磁盘存储划分,能节省系统开销。但相较传统的 VM 在隔离性上不那么好,毕竟还在一个宿主系统下面,如果这个宿主系统挂掉,上面的所有运行的容器都会挂掉。

 

 

docker 的核心组件

 

服务端(Server)和客户端(Client):C/S 架构,所有的执行都是通过服务端发送给客户端执行。

镜像(Image):需要运行的服务和运行环境封装在一起的包。

容器(Container):通过镜像运行起来的实例。

仓库(Repository):同一镜像可能有不同版本,这些包含同一镜像不同版本的地址就是该镜像的仓库。

注册点(Registry):各种仓库的集合地址就是注册点。

具体关系可以参照下图:

 

 

安装部署

 

docker 在网上的安装方式一般会看到这几种:curl 脚本安装,源码安装,yum 安装,rpm 安装。

通常对于生产环境尽量推荐选择 rpm 版本安装,原因在于便于版本控制。不安装最新的,怕有坑。

 

1. 安装准备:

下载方式可以选择 docker 官方镜像源:

https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

但是可能速度会很慢,所以也可以选择中科大提供的源:

http://mirrors.ustc.edu.cn/docker-ce/linux/centos/7/x86_64/stable/Packages/

我这里由于是测试版本,所以选择最新的 19.03.6-3 版本,下载所需的包:

containerd.io-1.2.6-3.3.el7.x86_64.rpm
docker-ce-19.03.6-3.el7.x86_64.rpm
docker-ce-cli-19.03.6-3.el7.x86_64.rpm

这里准备了 4 台 CentOS Linux release 7.5.1804 的虚拟机,IP 分别是 192.168.200.101-104,并事先关闭防火墙和 Selinux。

为了更好的支持,也可以升级一下机器的内核,当然如果你的服务器已经运行其他服务,最好不要升级,怕出问题。

具体升级方法可以参照我之前的博客,里面有一键升级脚本:

https://www.cnblogs.com/Dy1an/p/12011691.html

 

2. 安装依赖:

# 卸载旧版本
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

# 安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2 bridge-utils bash-completion wget container-selinux

# 更新系统
yum update

 

3. 上传之前下载的包并安装:

mkdir docker
cd docker/
# 上传文件到该目录下面,再执行安装
yum -y install *

 

4. 启动并设置开机自启:

systemctl start docker
systemctl enable docker
systemctl status docker

 

5. 查看:

docker version

结果如图:

 

6. 镜像仓库优化:

由于 docker 默认的镜像仓库 docker hub 因为某些不可描述的原因访问及其慢,可以将它换为国内的镜像源:

阿里镜像源:麻烦,需要专门申请账户。

中科大镜像源:直接配置即可。

# 拷贝启动文件
cp /lib/systemd/system/docker.service /etc/systemd/system

# 修改配置
sed -i "s#^ExecStart=.*#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --registry-mirror=https://docker.mirrors.ustc.edu.cn#g" /etc/systemd/system/docker.service

# 重启docker
chmod 755 /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl restart docker

此时查看 docker 进程:

ps -ef | grep docker

能够看到进程后面多了一个中科大镜像地址:

到此,docker 安装完成,接下来是 docker 的使用!

Guess you like

Origin www.cnblogs.com/Dy1an/p/12358044.html