千家信息网

Docker的简介与安装步骤

发表于:2025-12-06 作者:千家信息网编辑
千家信息网最后更新 2025年12月06日,这篇文章主要介绍"Docker的简介与安装步骤",在日常操作中,相信很多人在Docker的简介与安装步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"Docker的简介
千家信息网最后更新 2025年12月06日Docker的简介与安装步骤

这篇文章主要介绍"Docker的简介与安装步骤",在日常操作中,相信很多人在Docker的简介与安装步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"Docker的简介与安装步骤"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

Docker:
  • Docker是开源应用容器引擎,轻量级容器技术。

  • Docker可以让开发者打包他们的应用,依赖包及配置文件打包到一个轻量级,可移植的容器中,然后发布到任何流行的Linux系统上,也可以实现虚拟化。

  • 容器完全使用沙箱技术,互相之间不会有任何接口。

  • 类似于虚拟机技术(vmware,vitural),但docker直接运行再操作系统上,而不是运行再虚拟机中,速度块,,性能开销低。

  Docker支持将软件编译成一个镜像,然后再镜像中把各种软件做好配置,将镜像发布出去,其他使用者可以直接使用这个镜像。运行中的这个镜像称为容器,容器启动时非常快速的。

应用场景:
  • Web应用的自动化打包和发布。

  • 自动化测试和持续集成。

  • 在服务型环境中部署和调整数据库或其他后台应用。

  • 从头编译或扩展现有的OpenShift或Cloud Foundry平台来搭建自己的Paas环境。

Docker Client:

  Docker是C/S架构,客户端向守护进程发送请求,守护进程处理并返回给客户端。

Docker Daemon:

  Dcoekr Daemon为守护进程,后台运行,默认情况下,Docker Daemon只响应本地host的客户端请求,可以通过设置允许远程客户端请求。

Dcoker Image:
  • 一个只读模板,可以用来创建容器,一个镜像可以创建多个容器。

  • Docker提供了一个很简单的机制来创建和更新现有的镜像,甚至可以直接从其他人那里获取做好的镜像直接使用。

Docker Container:
  • 容器基于镜像来启动,可运行一个或多个应用。

  • Docker每个容器都是互相隔离的,保证安全。

Docker Registry:
  • 仓库是集中存放镜像的场所,类似于git代码仓库等。

  • 仓库和仓库注册服务区是有区别的。仓库注册服务器一般存放多个仓库,每个仓库又存放多个镜像,每个镜像又不同的标签。

  • 仓库分为公有仓库和私有仓库。

  • 最大的公有库为Docker Hub,国内有阿里云,daocloud等。

安装:

Docker官网:docs.docker.com

阿里云镜像站:mirrors.aliyun.com

gpgkey:https://mirrors.aliyun.com/docker-ce/linux/centos/gpgbaseurl:https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/

[root[@localhost](https://my.oschina.net/u/570656) ~]# cd /etc/yum.repos.d/[root[@localhost](https://my.oschina.net/u/570656) yum.repos.d]# lsCentOS-Base.repo       CentOS-Media.repoCentOS-CR.repo         CentOS-Sources.repoCentOS-Debuginfo.repo  CentOS-Vault.repoCentOS-fasttrack.repo[root[@localhost](https://my.oschina.net/u/570656) yum.repos.d]# vim Ali-docker.repo[Aliyun_docker]name=aliyun.com_dockerbaseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/enabled=1gpgcheck=1gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg[root[@localhost](https://my.oschina.net/u/570656) yum.repos.d]# yum -y install docker-ce[root[@localhost](https://my.oschina.net/u/570656) yum.repos.d]# systemctl start docker[root@localhost yum.repos.d]# docker versionClient: Docker Engine - Community    Version:           19.03.3    API version:       1.40    Go version:        go1.12.10    Git commit:        a872fc2f86    Built:             Tue Oct  8 00:58:10 2019    OS/Arch:           linux/amd64    Experimental:      falseServer: Docker Engine - Community    Engine:    Version:          19.03.3    API version:      1.40 (minimum version 1.12)    Go version:       go1.12.10    Git commit:       a872fc2f86    Built:            Tue Oct  8 00:56:46 2019    OS/Arch:          linux/amd64    Experimental:     false    containerd:    Version:          1.2.6    GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb    runc:    Version:          1.0.0-rc8    GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f    docker-init:    Version:          0.18.0    GitCommit:        fec3683
镜像加速:

Docker国内镜像站:daocloud.io

[root@localhost yum.repos.d]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.iodocker version >= 1.12{"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}Success.You need to restart docker to take effect: sudo systemctl restart docker [root@localhost yum.repos.d]# systemctl restart docker[root@localhost yum.repos.d]# docker infoClient: Debug Mode: falseServer: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 19.03.3 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: false Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-514.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 3.686GiB Name: localhost ID: KBZD:H3B4:ZFHE:KSPT:6IWI:QEVA:AFJV:EUR3:OJEB:HVJI:R5GW:GEZC Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/  #Registry已经改变为daocloud。 Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: http://f1361db2.m.daocloud.io/ Live Restore Enabled: false[root@localhost yum.repos.d]# cat /etc/docker/daemon.json   #可以通过这个文件来修改镜像源。{"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}
下载镜像:
[root@localhost yum.repos.d]# docker pull httpdUsing default tag: latestlatest: Pulling from library/httpdImage docker.io/library/httpd:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/b8f262c62ec6: Pull complete 2c31b9311798: Pull complete 7422a3cdf4e3: Pull complete 1919d4fbf9e1: Pull complete 60812fa1ab4c: Pull complete Digest: sha256:729508026fba8e00c15e2770f9eed52706b4065b68f29e4871222e22c3725bb7Status: Downloaded newer image for httpd:latestdocker.io/library/httpd:latest[root@localhost yum.repos.d]# docker pull centosUsing default tag: latestlatest: Pulling from library/centosImage docker.io/library/centos:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/729ec3a6ada3: Pull complete Digest: sha256:72942f390a71a1ecdebd4151c9bc4ff186fe8e480adcd7ddec84427118785482Status: Downloaded newer image for centos:latestdocker.io/library/centos:latest[root@localhost yum.repos.d]# docker pull busyboxUsing default tag: latestlatest: Pulling from library/busyboxImage docker.io/library/busybox:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/7c9d20b9b6cd: Pull complete Digest: sha256:be38efcd3a8289ff66e60c5652beed36968eeb856ae5d90f3cf02ea81e4a57daStatus: Downloaded newer image for busybox:latestdocker.io/library/busybox:latest[root@localhost yum.repos.d]# docker pull ubuntuUsing default tag: latestlatest: Pulling from library/ubuntuImage docker.io/library/ubuntu:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/5667fdb72017: Pull complete d83811f270d5: Pull complete ee671aafb583: Pull complete 7fc152dfb3a6: Pull complete Digest: sha256:ae7933206172662ff785dbf595a6f09e9d43858fa865725a9c51c589ed482901Status: Downloaded newer image for ubuntu:latestdocker.io/library/ubuntu:latest[root@localhost yum.repos.d]# docker pull registry:22: Pulling from library/registryImage docker.io/library/registry:2 uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/c87736221ed0: Pull complete 1cc8e0bb44df: Pull complete 54d33bcb37f5: Pull complete e8afc091c171: Pull complete b4541f6d3db6: Pull complete Digest: sha256:b224aa2d9a6397e9102b0b887a3e92496eadd76872efb7595bed97f9b76d2056Status: Downloaded newer image for registry:2docker.io/library/registry:2[root@localhost yum.repos.d]# docker pull progrium/consulUsing default tag: latestlatest: Pulling from progrium/consulImage docker.io/progrium/consul:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/c862d82a67a2: Pull complete 0e7f3c08384e: Pull complete 0e221e32327a: Pull complete 09a952464e47: Pull complete 60a1b927414d: Pull complete 4c9f46b5ccce: Pull complete 417d86672aa4: Pull complete b0d47ad24447: Pull complete fd5300bd53f0: Pull complete a3ed95caeb02: Pull complete d023b445076e: Pull complete ba8851f89e33: Pull complete 5d1cefca2a28: Pull complete Digest: sha256:8cc8023462905929df9a79ff67ee435a36848ce7a10f18d6d0faba9306b97274Status: Downloaded newer image for progrium/consul:latestdocker.io/progrium/consul:latest[root@localhost yum.repos.d]# docker pull progrium/stressUsing default tag: latestlatest: Pulling from progrium/stressImage docker.io/progrium/stress:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/a3ed95caeb02: Pull complete 871c32dbbb53: Pull complete dbe7819a64dd: Pull complete d14088925c6e: Pull complete 58026d51efe4: Pull complete 7d04a4fe1405: Pull complete 1775fca35fb6: Pull complete 5c319e267908: Pull complete Digest: sha256:e34d56d60f5caae79333cee395aae93b74791d50e3841986420d23c2ee4697bfStatus: Downloaded newer image for progrium/stress:latestdocker.io/progrium/stress:latest
Docker进程监听:
[root@localhost yum.repos.d]# vim /usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0 --containerd=/run/containerd/containerd.sock   #添加:-H tcp://0.0.0.0[root@localhost yum.repos.d]# systemctl daemon-reload [root@localhost yum.repos.d]# systemctl restart docker
docker远程操作:

被连接端:

[root@localhost yum.repos.d]# netstat -anput | grep dockertcp6     0      0 :::2375                 :::*                    LISTEN      7211/dockerd    [root@localhost yum.repos.d]# iptables -F  #需要放行2375端口。[root@localhost yum.repos.d]# iptables-save

主动连接端:

[root@localhost ~]# systemctl start docker[root@localhost ~]# iptables -F  [root@localhost ~]# iptables-save [root@localhost ~]# docker -H 被连接端ip options

到此,关于"Docker的简介与安装步骤"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!

镜像 仓库 容器 应用 运行 步骤 简介 多个 客户 客户端 进程 学习 技术 服务 可以通过 后台 文件 更多 环境 系统 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 移动光猫usb口打印服务器 嘉定区管理网络技术服务市价 数据库概论第三章思维导图 数据库中的信息都是什么 宝山区无线网络技术价格对比 服务器获取客户端ip ui设计软件开发介绍 云服务器靠什么赚钱 计算机网络技术军队 前沿信息技术 网络技术 csgo服务器允许盗版插件 上海泽汐互联网科技有限公司 我市举行网络安全攻防演练 广州资金盘软件开发 主题网络安全升旗仪式 南通沃太能源软件开发怎么样 idea连接数据库jar包 互联网科技产品怎么样 阿里云git服务器 邮政银行基地软件开发是编制嘛 有哪些软件开发框架平台 进销存软件用的什么数据库 同上一堂网络安全课主题 宝山区无线网络技术价格对比 南阳天宇网络技术开发公司 华宝服务器ip 同一台服务器ip放多个网站 数据库中两张表中的数据比对 boat进mod服务器 邮政银行基地软件开发是编制嘛
0