当前位置: 首页 > news >正文

docker的安装及部署

单机文件系统:
ntfs – windows
xfs – linux
ext4 – linux
集群文件系统
vmfs
ocfs

安装docker

准备stream8虚拟机

1.配置主机名及ip

[root@localhost ~]# hostnamectl set-hostname docker[root@localhost ~]# nmcli connection modify ens160 ipv4.method manualipv4.addresses 192.168.108.30/24 ipv4.gateway 192.168.108.2 ipv4.dns 192.168.108.2 autoconnect yes[root@localhost ~]# nmcli con up ens160

2.卸载旧版本

[root@docter ~ 11:44:55]# yum remove docter-ceNo matchforargument: docter-ce No packages markedforremoval.Dependencies resolved.Nothing todo.Complete!

3.安装必要工具

[root@docter ~ 11:45:23]# yum install -y yum-utils device-mapper-persistent-data lvm2 vim[root@docter ~ 11:46:55]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo[root@docter ~ 11:47:31]# yum makecacheDocker CE Stable-x86_64 40 kB/s|66 kB 00:01 CentOS Stream 8-BaseOS 4.2 kB/s|3.9 kB 00:00 CentOS Stream 8-AppStream 533 B/s|4.4 kB 00:08 Metadata cache created.

4.安装软件

[root@docker ~ 12:18:35]# yum install -y docker-ce

5.配置服务

[root@docker ~ 12:20:11]# systemctl enable docker.service --nowCreated symlink/etc/systemd/system/multi-user.target.wants/docker.service →/usr/lib/systemd/system/docker.service.##查看docker版本[root@docker ~ 12:21:55]# docker --versionDocker version 26.1.3,build b72abbb##查看状态[root@docker ~ 12:26:12]# systemctl status docker.service● docker.service-Docker Application Container Engine Loaded: loaded(/usr/lib/systemd/system/docker.service;enabled;vendor preset: disabled)Active: active(running)since Fri 2026-05-08 12:21:55 CST;4min 33s ago Docs: https://docs.docker.com Main PID: 11781(dockerd)Tasks: 10 Memory: 32.2M CGroup:/system.slice/docker.service └─11781/usr/bin/dockerd-H fd://--containerd=/run/containerd/containerd.sock

配置镜像加速器


[root@docker ~ 13:33:10]# vi /etc/docker/daemon.json{"registry-mirrors":["https://019e062e72da7ba3b57dd0af5f1b27.mirror.swr.myhuaweicloud.com"]}##重新启动docker[root@docker ~ 14:04:58]# systemctl restart docker##确认配置[root@docker ~ 14:05:15]# docker infoClient: Docker Engine-Community Version: 26.1.3 Context: default Debug Mode: false Plugins: buildx: Docker Buildx(Docker Inc.)Version: v0.14.0 Path:/usr/libexec/docker/cli-plugins/docker-buildx compose: Docker Compose(Docker Inc.)Version: v2.27.0 Path:/usr/libexec/docker/cli-plugins/docker-compose Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 26.1.3 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: trueUsingmetacopy: false Native OverlayDiff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: 8b3b7ca2e5ce38e8f31a34f35b2b68ceb8470d89 runc version: v1.1.12-0-g51d5e94 init version: de40ad0 Security Options: seccomp Profile: builtin Kernel Version: 4.18.0-553.6.1.el8.x86_64 Operating System: CentOS Stream 8 OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 3.549GiB Name: docker ID: d36b4833-5f04-4848-9ca3-d6130d8221c4 Docker RootDir:/var/lib/docker Debug Mode: false Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: https://019e062e72da7ba3b57dd0af5f1b27.mirror.swr.myhuaweicloud.com/##观察这边显示地址就行Live Restore Enabled: false

运行第一个容器

[root@docker ~ 14:08:44]# docker run hello-worldUnable to find image'hello-world:latest'locally##观察latest: Pullingfromlibrary/hello-world 4f55086f7dd0: Pull complete##观察Digest: sha256:f9078146db2e05e794366b1bfe584a14ea6317f027d10ef7dad65279026885 Status: Downloaded newer imageforhello-world:latest HellofromDocker!###观察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"imagefromthe Docker Hub.(amd64)3.The Docker daemon created a new containerfromthat 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.Totrysomething 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/Formore examples and ideas,visit: https://docs.docker.com/get-started/

其过程可以简单的描述为:

  1. 从本地查找hello-wrold镜像,没找到
  2. 从 Docker Hub 下载hello-world镜像。
  3. 启动hello-world容器
    清空刚才的实验环境: 随后关机快照
#删除所有容器[root@docker ~ 14:11:27]# docker rm -f $(docker ps -aq)#删除镜像hello-world[root@docker ~ 14:12:44]# docker rmi -f hello-world

Docker 五大核心组件及作用

Docker Client 客户端:命令行交互入口,发指令给服务端。
Docker Daemon 服务器:后台服务,接收指令、管理容器 / 镜像。
Docker Image 镜像:容器只读模板,包含运行环境和应用。
Docker Container 容器:镜像运行实例,独立隔离的应用运行环境。
Docker Registry 仓库:存放、共享镜像的仓库(如 Docker Hub)

docker C/S分离部署

配置俩台虚拟机
docker_server 192.168.108.30 and docker_client 192.168.108.31
分别配置主机名和ip

1.server配置

[root@docker_server ~]# yum install -y yum-utils device-mapper-persistent-datalvm2 vim[root@localhost ~]# yum-config-manager --add-repohttps://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo Adding repofrom: https://mirrors.aliyun.com/docker-ce/linux/centos/dockerce.repo[root@docker_server ~]# yum makecache[root@docker_server ~]# yum install -y docker-ce[root@docker_server ~]# systemctl enable docker.service --now[root@docker_server ~]# vi /etc/docker/daemon.json{"registry-mirrors":["https://054b8ac70e8010d90f2ac00ef29e6580.mirror.swr.myhuaweicloud.com"]}# 按“Esc”,输入:wq保存并退出。#重启容器引擎[root@docker_server ~]# systemctl restart docker

配置服务

[root@docker_server ~]# vim /usr/lib/systemd/system/docker.service# 在ExecStart参数中最后添加 -H tcp://0.0.0.0:2375,docker默认监听2375ExecStart=/usr/bin/dockerd-H fd://--containerd=/run/containerd/containerd.sock-H tcp://0.0.0.0:2375[root@docker_server ~]# systemctl daemon-reload[root@docker_server ~]# systemctl restart docker.service[root@docker_server ~]# systemctl stop firewalld

2.client配置

[root@docker-client ~]# yum install -y yum-utils device-mapper-persistent-datalvm2 vim[root@docker-client ~]# yum-config-manager --add-repohttps://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo Adding repofrom: https://mirrors.aliyun.com/docker-ce/linux/centos/dockerce.repo[root@docker-client ~]# yum makecache[root@docker-client ~]# yum install -y docker-ce-cli

验证

# client端连接server端执行命令[root@docker-client ~]# docker -H 192.168.108.30 run hello-worldHellofromDocker! 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"imagefromthe Docker Hub.(amd64)3.The Docker daemon created a new containerfromthat 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.Totrysomething 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/Formore examples and ideas,visit: https://docs.docker.com/get-started/

查看内核

[root@docker ~ 16:23:18]# docker pull centos:77: Pullingfromlibrary/centos 2d473b07cdd5: Pull complete Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Status: Downloaded newer imageforcentos:7 docker.io/library/centos:7[root@docker ~ 16:24:00]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE centos 7 eeb6ee3f44bd 4 years ago 204MB[root@docker ~ 16:24:11]# uname -r4.18.0-553.6.1.el8.x86_64[root@docker ~ 16:24:34]# docker run -it centos:7[root@5c0b369a00ee /]# uname -r4.18.0-553.6.1.el8.x86_64[root@5c0b369a00ee /]# exitexit##公用一个宿主机内核
http://www.jsqmd.com/news/805753/

相关文章:

  • 清华系团队造出能“边听边说、边看边想“的AI耳朵MiniCPM-o 4.5
  • 深度解析英飞凌BGA824N6:GNSS低噪声放大器中的“性能标杆”
  • 3分钟完成Windows和Office永久激活:KMS智能激活脚本终极指南
  • 全站技术栈被动指纹嗅探,集成 Vue 路由审计与 API 批量检测,自动挖掘支付逻辑高危洞
  • 花生矮砧密植水肥一体化系统铺设全指南
  • 202X年CSDN年度技术趋势大预测
  • A股T+0策略回测框架autoxd:Pandas-First设计与实战指南
  • 解决Elsevier参考文献的不同形式
  • OpenClaw引发AI Agent狂欢,深圳机密计算科技打造全链路安全基座
  • ECA:编辑器无关的AI编程伴侣,统一配置多模型与编辑器
  • 当 AI 能写代码,Python 优势不再?难学语言借 AI 逆袭
  • 光子计算:突破AI算力瓶颈的新兴技术
  • 2026年曳引电梯公司选择标准解析与成都乐仕机电设备有限公司推荐 - 2026年企业推荐榜
  • 人工智能体共情能力模块设计与实践(下)
  • 基于工具调用架构的终端AI助手:从原理到实践
  • 第三篇:CPU缓存——为什么有时候改了一行代码,性能差了百倍
  • 车载BLDC电机驱动设计:IPM技术选型与工程实践全解析
  • AI编程助手上下文管理工具devcontext:构建项目记忆库提升开发效率
  • Enzyme协议:DeFi资产管理智能合约架构与实战指南
  • 99美元超算Parallella实战:量子模拟的异构计算与能效优化
  • spring生命周期
  • 为什么92%的设计师在Basic计划第3周放弃?——基于1,842份用户行为日志的紧迫预警
  • 2026年四川轻奢入户门权威推荐指南:四川家装入户门/四川小区入户门/四川指纹锁门/四川新房入户门/四川旧房换门/选择指南 - 优质品牌商家
  • 2026金铲铲之战电脑版模拟器实测:选对模拟器轻松上分
  • AI时代工程师的超能力进化
  • 3分钟快速上手:如何用res-downloader高效下载视频号资源
  • 基于 Harmony6.0 的智慧学习应用页面构建实战:从组件封装到跨端 UI 设计
  • day13-C语言-指针
  • 开源OmenSuperHub:解决惠普OMEN笔记本性能限制的完整技术方案
  • 合肥元森倍健:营养榧塑膳食/香榧产地/香榧价值/香榧作用/香榧功效/香榧瘦身产品/天然榧塑膳食/天然膳食/安徽香榧种植园/选择指南 - 优质品牌商家