技术标签: 【容器技术-Docker】 运维 docker
使用Docker技术可以帮助企业快速水平扩展服务,从而到达弹性部署业务的能力。
在云服务概念兴起之后,Docker的使用场景和范围进一步发展,如今在微服务架构越来越流行的情况下,微服务+Docker的完美组合,更加方便微服务架构运维部署落地。
Docker 属于 Linux 容器的一种封装,提供简单易用的容器使用接口。它是目前最流行的 Linux 容器解决方案。
Docker 将应用程序与该程序的依赖,打包在一个文件里面。运行这个文件,就会生成一个虚拟容器。程序在这个虚拟容器里运行,就好像在真实的物理机上运行一样。
简而言之, 用户可以方便地创建和使用容器,把自己的应用放入容器。容器还可以进行版本管理、复制、分享、修改,就像管理普通的代码一样。
1、更快速的交付和部署
容器的启动时间是秒级的,大量地节约开发、测试、部署的时间。
2、更高效的虚拟化
Docker 容器的运行不需要额外的 hypervisor 支持,它是内核级的虚拟化,因此可以实现更高的性能和效率。
3、更轻松的迁移和扩展
Docker 容器几乎可以在任意的平台上运行 ,这种兼容性可以让用户把一个应用程序从一个平台直接迁移到另外一个。
4、更简单的管理
使用 Docker,只需要小小的修改,就可以替代以往大量的更新工作。所有的修改都以增量的方式被分发和更新,从而实现自动化并且高效的管理。
Docker 在容器的基础上,进行了进一步的封装,从文件系统、网络互联到进程隔离等等,极大的简化了容器的创建和维护。使得 Docker 技术比虚拟机技术更为轻便、快捷
Docker 跟传统的虚拟化方式相比具有众多的优势。
Docker是CS架构,主要有两个概念:
Docker daemon
运行在宿主机上,Docker守护进程,用户通过Docker client(Docker命令)与Docker daemon交互
Docker client
Docker 命令行工具,是用户使用Docker的主要方式,Docker client与Docker daemon通信并将结果返回给用户,Docker client也可以通过socket或者RESTful api访问远程的Docker daemon
了解了Docker的组成,再来了解一下Docker的三个主要概念:
Docker image
镜像是只读的,镜像中包含有需要运行的文件。镜像用来创建container,一个镜像可以运行多个container;镜像可以通过Dockerfile创建,也可以从Docker hub/registry上下载。
Docker container
容器是Docker的运行组件,启动一个镜像就是一个容器,容器是一个隔离环境,多个容器之间不会相互影响,保证容器中的程序运行在一个相对安全的环境中。
Docker hub/registry
共享和管理Docker镜像,用户可以上传或者下载上面的镜像,官方地址为https://registry.hub.docker.com/,也可以搭建自己私有的Docker registry。
镜像就相当于打包好的版本,镜像启动之后运行在容器中,仓库就是装存储镜像的地方。
建议在linux环境下安装Docker, 使用Centos7+yum来安装Docker
内核3.10及以上
[root@VM-0-7-centos ~]# uname -r
3.10.0-1160.11.1.el7.x86_64
[root@VM-0-7-centos ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Packages marked for removal
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
elk | 2.9 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/5): extras/7/x86_64/primary_db | 243 kB 00:00:00
(2/5): epel/7/x86_64/updateinfo | 1.0 MB 00:00:00
(3/5): elk/primary_db | 590 kB 00:00:00
(4/5): epel/7/x86_64/primary_db | 7.0 MB 00:00:00
(5/5): updates/7/x86_64/primary_db | 11 MB 00:00:01
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
[root@VM-0-7-centos ~]#
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo # 默认是国外的
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 阿里云镜像仓库(推荐)
那必须整国内的呀
[root@VM-0-7-centos ~]# yum-config-manager \
> --add-repo \
> http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# yum makecache fast
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
docker-ce-stable | 3.5 kB 00:00:00
elk | 2.9 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/primary_db | 64 kB 00:00:00
(2/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
Metadata Cache Created
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# yum install docker-ce docker-ce-cli containerd.io
一路 y
直到看到
Installed:
containerd.io.x86_64 0:1.4.10-3.1.el7 docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-cli.x86_64 1:20.10.8-3.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 docker-ce-rootless-extras.x86_64 0:20.10.8-3.el7
docker-scan-plugin.x86_64 0:0.8.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8
fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7
libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7
python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8
Complete!
[root@VM-0-7-centos ~]# systemctl start docker
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker version
Client: Docker Engine - Community
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:55:49 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Fri Jul 30 19:54:13 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.10
GitCommit: 8848fdb7c4ae3815afcc990a8a99d663dda1b590
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:9ade9cc2e26189a19c2e8854b9c8f1e14829b51c55a630ee675a5a9540ef6ccf
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/
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 10 days ago 13.3kB
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#yum remove docker-ce docker-ce-cli containerd.io
[root@VM-0-7-centos ~]#rm -rf /var/lib/docker
[root@VM-0-7-centos ~]#rm -rf /var/lib/containerd
登录阿里云,找到容器镜像服务,找到镜像加速器
[root@VM-0-7-centos ~]# mkdir -p /etc/docker
[root@VM-0-7-centos ~]# tee /etc/docker/daemon.json <<-'EOF'
> {
> "registry-mirrors": ["https://0uf1zwdk.mirror.aliyuncs.com"]
> }
> EOF
{
"registry-mirrors": ["https://0uf1zwdk.mirror.aliyuncs.com"]
}
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://0uf1zwdk.mirror.aliyuncs.com"]
}
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# systemctl daemon-reload
[root@VM-0-7-centos ~]# systemctl restart docker
[root@VM-0-7-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 10 days ago 13.3kB
[root@VM-0-7-centos ~]#
文章浏览阅读1w次,点赞20次,收藏74次。本专栏为收费专栏的文章目录,对应的免费专栏为《[PyQt入门知识目录](https://blog.csdn.net/laoyuanpython/category_9702362.html)》,两个专栏都为基于PyQt的Python图形界面开发基础教程,只是收费专栏中的内容介绍更深入、案例代码更全。Qt和PyQt介绍的很多部件属性及字典取值在Qt及PyQt官方文档以及网上都没有,老猿通过大量研究、测试将相关内容弄清楚,因此本专栏适合有一定Python基础的同仁零基础学习Python图形界面开发,也适合学习_pythonqt图形界面开发
文章浏览阅读293次,点赞8次,收藏5次。“一带一路”成功属于世界-万祥军|谋定研究·国家(中国)智库
文章浏览阅读935次。在Windows XP Home版中安装IIS 本文转自 互联网 http://www.hi-search.com/post/50.html大家知道,Windows XP Home版不能安装IIS或者PWS。按照一般的方法,你只能升级到XP Professional或者使用Windows 2000,不过只要略使手段,你就可以在Windows XP Home上安装IIS了。 首先在“开始”菜
文章浏览阅读909次,点赞3次,收藏4次。一、实验环境(rhel7.5版本)1.selinux和firewalld状态为disabled2.各主机信息如下:主机ipserver2(zabbix-agent)172.25.63.2server3(zabbix-agent)172.25.63.3server4(zabbix-server)172.25.63.4二、zabbix-server的部..._zabbix redhat部署
文章浏览阅读1.2w次,点赞4次,收藏28次。假设有一个父maven项目project,有三个子模块producer,consumer和common,其中producer依赖common,consumer也依赖于common,也就是producer,consumer的pom.xml文件中导入了common模块第一种方式:使用idea自带的打包方式快捷键Ctr+Alt+Shift+S弹出以下画面查看打包出来的jar可以看到这种打包方式打包出来的jar包中包含..._idea 多module maven打包
文章浏览阅读536次。实现BeanDefinitionRegistryPostProcessor@Componentpublic class SmsBeanDefinitionRegistry implements BeanDefinitionRegistryPostProcessor, ResourceLoaderAware, ApplicationContextAware, InitializingBean { private ApplicationContext applicationContext; _如何代理beanfactory
文章浏览阅读375次。家里的一个儿童澡盆附带的温度计坏掉了,拆解后发现这东西做的真垃圾!索性自己做一个。拆下了里面的NTC热敏电阻,但是不知道NTC的性能参数,经过测量与查资料后,采用用。_float temper=0.0;
文章浏览阅读824次。三维工厂K3DMaker是一款三维模型浏览、分析、轻量化、顶层合并构建、几何校正、格式转换、调色裁切等功能专业处理软件。可以进行三维模型的网格简化、纹理压缩、层级优化等操作,从而实现三维模型轻量化。轻量化压缩比大,模型轻量化效率高,自动化处理能力高;采用多种算法对三维模型进行几何精纠正处理,精度高,处理速度快,超大模型支持;优秀数据处理和转换工具,支持将OSGB格式三维模型转换为3DTiles等格式,可快速进行转换。_3dtile
文章浏览阅读2.4w次,点赞14次,收藏41次。MacBooK添加应用(以腾讯会议为例)的麦克风权限新换了mbp pro,开个会,发现腾讯会议麦克风没声,在系统偏好设置-安全性与隐私-隐私-麦克风里,并没有腾讯会议这个应用,于是会议用手机开的????。我在网上找到了两个教程,很nice,但是要结合着看,不是很完整,原文章链接:https://blog.csdn.net/qq_34029469/article/details/107284443https://blog.csdn.net/weixin_42634260/article/details/_mac 隐私 麦克风 com.tencent.meeting
文章浏览阅读1.2k次。open你的jar包路径把你的jar包 add as libraly选择你的jar包 右键 -> Add as Library完成jar左边出现下拉框选择,打开就可以查看了_idea反编译能拿到源码吗
文章浏览阅读2k次。数字经济时代传递新商机,城链科技布局进入加速度。2022年7月5日,城链科技数字化战略峰会在古都西安大唐西市酒店盛大召开,吸引了众多链商,实体企业精英,业内大咖等人士参加,现场人气十分火爆。峰会在震撼人心的音乐中拉开序幕,一场围绕以区块链技术驱动数字经济时代发展的商业盛会就此展开。 城链科技总裁姚迦宝携公司高管出席了峰会并发表致辞。姚迦宝在致辞时表示:区块链技术作为数字经济时代的标志性技术,对于促进实体产业升级,加快商品流通具有重要意义,而城链科技的使命就是助力实体经济振兴和繁荣,激发大消费市场活力,通过
文章浏览阅读107次。通过环境检测设备可以监测到公厕的空气质量情况,并自动触发除臭杀菌消毒系统,这样一来,不仅能够更好地满足市民的需求,还能够提升公共厕所的服务环境。总结起来,智慧公厕管理系统的建设对公共厕所的使用、维护、管理、保养等环节都起到了极大的改善作用。未来,随着智能科技的不断发展,相信智慧公厕管理系统将进一步完善,为城市的公厕问题提供更加优质和便捷的解决方案。智慧公厕管理系统通过将先进的技术与传统的公厕管理相结合,实现了公厕的智能监测、自动化运维、实时异常告警等功能,极大地提升了公共厕所的使用体验和管理效率。_智慧公厕系统巡检