docker 卸载镜像_docker 入门到精通(一)

1af9b8e2068cdf47e3bd5ef9a458bcd2.png

1、docker 是什么

没有 docker 之前,需要把一套环境用到的所有工具都部署一遍,花费的时间非常久。
有了 docker 之后,你只需要把环境打包成一个镜像,复制到另外一台服务器上安装镜像即可。

38d92d5026b65b5c8ed4f01f6e93c83b.gif
官网:https://www.docker.com/

docker 能干什么?

虚拟化软件运行环境,以最小的代价换取最大的资源。比如以前一台服务器只能同时跑 3 个 Redis,用了 docker 之后能跑 30 个。并且每个 Redis 是相互隔离的,这也是 docker 图标上集装箱所想表达的思想。

2、docker 中的名词概念

573a1e2609b1a7ef83bfa9010129d573.png
仓库(repository):Docker hub,存放在镜像的地方,国内可配置镜像加速下载。
镜像(image):是一个模块,可基于此模板运行处多个容器。
容器(container):通过镜像创建的独立运行的一个或一组应用。

3、安装 docker

docker 文档:https://docs.docker.com/

d62e3dd4628de98b10fc76765f0a7eb5.png

Linux 系统要求

CentOS 7 或者更高版本。

卸载老版本

# 卸载老版本
$ sudo yum remove docker 
                  docker-client 
                  docker-client-latest 
                  docker-common 
                  docker-latest 
                  docker-latest-logrotate 
                  docker-logrotate 
                  docker-engine
# 删除资源目录
rm -rf /var/lib/docker

配置国内镜像加速

mkdir -p /etc/docker
vi daemon.json 
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}

systemctl daemon-reload
systemctl restart docker

4、Hello World

[root@localhost ~]# docker run hello-world
#############################从docker hub下载hello-world镜像###############################
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec
Status: Downloaded newer image for hello-world:latest
############################运行hello-world容器############################################
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 hello-world 运行流程

docker 先在本地寻找 hello-world 镜像没有找到就会去 docker hub 中下载,下载完成之后 docker 运行容器 hello-world,后台会有一个守护进程,所谓的守护进程可以理解为一个 24 小时不中断运行的程序。我们通过 docker 命令调用守护进程,执行对应的方法完成操作。

docker 底层原理图

af8c15bc33f0ad528cac90917c43fb23.png
docker 为什么快,因为他不需要 Guest OS, Guest OS 就是你在虚拟机中安装的 CentOS、Ubuntu,Guest OS 启动时需要进行很多引导操作,非常消耗性能。而 docker 直接利用宿主机的内容加上 docker engine 就能运行容器,极大的节省了性能开销。所以说 docker 是秒级,虚拟机是分钟级。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值