Docker安装及加速
Docker安装简介
Docker是一个开源项目 ,其主要目标是实现轻量级的操作系统虚拟化解决方案。Docker的基础是Linux容器(LXC)等技术。在LXC的基础上Docker进行了进一步的封装,让用户不需关心容器的管理,使得操作变得简单。
安装需求背景:虚拟终端中安装环境
安装docker
- 使用软件包管理工具下载这里推荐使用yum
yum是软件包管理工具
通过 执行 man yum
可以查看yum的帮助信息
2.设置下载docker的镜像源
下载完毕后,设置下载的镜像源,如果不设置,会默认去Docker的官方下载,但是官方的服务器在国外,下载会比较缓慢,设置下载国内的镜像源 使用国内的阿里云
3.安装Docker
这个命令可提前在本地缓存一份,用来提高软件安装速度
yum makecache fast
高安装速度以后,安装docker相关的
yum install docker-ce docker-ce-cli containerd.io
4.启动,并设置为开机自动启动,测试
4.1启动Docker服务
systemctl start docker
4.2 设置开机自动启动
systemctl enable docker
4.3 测试
docker run hello-world
成功示例说明成功:
[root@iZ2ze68ge5c1uwlkmnb9ixZ zcapp]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe
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/
如果出现紫色标注的部分,说明Docker run hello-world命令运行成功了
也可输入以下命令查看hello-world镜像是否下载成功:docker images
上图中红色方框中:
REPOSITORY 镜像的仓库源
TAG 镜像的标签
IMAGE ID 镜像的id
CREATED 镜像的创建时间
SIZE 镜像的大小
看到hell-wold 这个镜像是存在的
最后安装完成