- VisualStudio2022插件的安装及使用-编程手把手系列文章
- pprof-在现网场景怎么用
- C#实现的下拉多选框,下拉多选树,多级节点
- 【学习笔记】基础数据结构:猫树
Docker 是一个强大的工具,用于高效开发、打包和部署应用程序。Docker 是一种容器管理服务。Docker 于 2013 年发布。它是开源的,可用于 Windows、macOS 和 Linux 等不同平台。Docker 正在快速交付、测试和部署代码。这样可以减少编写代码和在生产环境中运行代码之间的延迟。您可以创建称为容器的自包含环境。它可以在不同的平台上一致地运行.
Docker 是一组平台即服务 (PaaS) 产品,它使用操作系统级虚拟化以称为容器的包的形式交付软件。容器彼此隔离,并捆绑自己的软件、库和配置文件;他们可以通过定义明确的渠道相互通信。所有容器都由单个操作系统内核运行,因此使用的资源比虚拟机少.
Docker 是一个开源 容器化 平台,通过该平台,您可以将应用程序及其所有依赖项打包到一个称为容器的标准化单元中。容器重量轻,这使得它们具有可移植性,并且它们与底层基础设施和其他容器隔离。您可以在任何安装了 docker 的计算机上将 docker 镜像 作为 docker 容器运行,而无需依赖 操作系统.
Docker 因其对软件开发和部署的影响而广受欢迎。以下是 docker 流行的一些主要原因:
以下是 Docker 的一些关键组件:
Docker 使用客户端-服务器架构。Docker 客户端与 docker 守护程序通信,这有助于构建、运行和分发 docker 容器。Docker 客户端与守护程序在同一系统上运行,或者我们可以远程将 Docker 客户端与 Docker 守护程序连接。在 UNIX 套接字或网络上的 REST API 的帮助下,docker 客户端和守护程序可以相互交互.
Docker 守护程序通过与其他守护程序通信来管理所有服务。它借助 Docker 的 API 请求管理 Docker 对象,例如映像、容器、网络和卷.
在 docker 客户端的帮助下,docker 用户可以与 docker 交互。docker 命令使用 Docker API。Docker 客户端可以与多个守护程序通信。当 docker 客户端在 docker 终端上运行任何 docker 命令时,终端会向守护进程发送指令。Docker 守护程序从命令形状和 REST API 请求内的 docker 客户端获取这些指令.
docker 客户端的主要目标是提供一种方法来指导从 docker 注册表中提取镜像并在 docker 主机上运行它们。客户端使用的常用命令是 docker build、docker pull 和 docker run.
Docker 主机是一种负责运行多个容器的机器。它包括 Docker 守护程序、映像、容器、网络和存储.
所有 docker 镜像都存储在 docker 注册表中。有一个公共注册表,称为 docker hub,任何人都可以使用。我们也可以运行我们的私有注册表。在 docker run 或 docker pull 命令的帮助下,我们可以从配置的注册表中提取所需的镜像。在 docker push 命令的帮助下,镜像被推送到配置的注册表中.
每当我们使用 docker 时,我们都会创建和使用镜像、容器、卷、网络和其他对象。现在,我们将讨论 docker 对象:- 。
镜像包含创建 Docker 容器的说明。它只是一个只读模板。它用于存储和交付应用程序。映像是 docker 体验的重要组成部分,因为它们以以前无法实现的任何方式支持开发人员之间的协作.
容器是从 docker 镜像创建的,因为它们是现成的应用程序。在 Docker API 或 CLI 的帮助下,我们可以启动、停止、删除或移动容器。容器只能访问映像中定义的那些资源,除非在容器中构建映像期间定义了其他访问权限.
我们可以将数据存储在容器的可写层中,但它需要一个存储驱动程序。存储驱动程序控制和管理 Docker 主机上的镜像和容器.
以下是 Docker 中常见的数据持久化方法:
Docker 网络为 Docker 容器提供完全隔离。这意味着用户可以将 docker 容器链接到多个网络。它需要的操作系统实例非常少来运行工作负载.
网络模式说明 。
网络模式 | 配置 | 说明 |
---|---|---|
bridge | --network=bridge | 为每个容器分配 IP 。并将容器连接到 docker0 虚拟网桥上,这种模式是默认模式 |
host | --network=host | 容器不会创建自己的网卡,配置 IP 等,而是使用宿主机的 IP 和端口 |
none | --network=none | 容器关闭网络功能,不进行任何网路设置 |
container | --network=container | 容器不会创建自己的网卡和IP,而是和一个指定的容器共享 IP 和端口 |
custom | --network=new_bridge | 为每个容器分配 IP 。并将容器连接到自定义的虚拟网桥上 |
系统要求:Docker 支持 64 位版本 CentOS 7/8,并且要求内核版本不低于 3.10。 CentOS 7 满足最低内核的要求,但由于内核版本比较低,部分功能(如 overlay2 存储层驱动)无法使用,并且部分功能可能不太稳定.
如需升级 Linux 内核参考《CentOS 7 内核升级最新记录(yum及编译)》 。
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]# uname -r
3.10.0-1160.el7.x86_64
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -i.bak '7s/enforcing/disabled/' /etc/selinux/config
[root@localhost ~]# swapoff -a
[root@localhost ~]# sed -ri.bak 's/.*swap.*/#&/' /etc/fstab
[root@localhost ~]# systemctl stop firewalld && systemctl disable firewalld
[root@localhost ~]# firewall-cmd --state
not running
# 更换阿里源
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
时间:2024-09 。
# 卸载旧版本
[root@localhost ~]# yum remove docker docker-client docker-client-latest docker-common docker-latest \
docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
# 安装所需的软件包。yum-utils 提供了 yum-config-manager
[root@localhost ~]# yum install -y yum-utils
# 添加 yum 软件源(三选一)
[root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 阿里源
yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo # 清华大学源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo # 官方源(较慢)
# 列出存储库中可用的版本。按版本号(从高到低)
[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
* extras: mirrors.aliyun.com
docker-ce.x86_64 3:26.1.4-1.el7 docker-ce-stable
docker-ce.x86_64 3:26.1.3-1.el7 docker-ce-stable
docker-ce.x86_64 3:26.1.2-1.el7 docker-ce-stable
docker-ce.x86_64 3:26.1.1-1.el7 docker-ce-stable
docker-ce.x86_64 3:26.1.0-1.el7 docker-ce-stable
docker-ce.x86_64 3:26.0.2-1.el7 docker-ce-stable
docker-ce.x86_64 3:26.0.1-1.el7 docker-ce-stable
docker-ce.x86_64 3:26.0.0-1.el7 docker-ce-stable
docker-ce.x86_64 3:25.0.5-1.el7 docker-ce-stable
docker-ce.x86_64 3:25.0.4-1.el7 docker-ce-stable
docker-ce.x86_64 3:25.0.3-1.el7 docker-ce-stable
docker-ce.x86_64 3:25.0.2-1.el7 docker-ce-stable
docker-ce.x86_64 3:25.0.1-1.el7 docker-ce-stable
docker-ce.x86_64 3:25.0.0-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.9-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.8-1.el7 docker-ce-stable
# 安装最新版本
[root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io
# 若选择版本安装 例如docker-ce-24.0.9
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
# 若选择测试版本的 Docker 请执行以下命令
yum-config-manager --enable docker-ce-test
# 验证
[root@localhost ~]# docker -v
Docker version 26.1.4, build 5650f9b
# 添加国内镜像加速(每次修改需重启 docker)
[root@localhost ~]# cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://mirror.baidubce.com",
"https://mirror.ccs.tencentyun.com",
"https://wxvmh7l6.mirror.aliyuncs.com",
"https://hub.atomgit.com",
"https://registry.docker-cn.com",
"https://mirrors.tuna.tsinghua.edu.cn",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
EOF
# 启动
[root@localhost ~]# systemctl daemon-reload && systemctl start docker
# 测试 Docker 是否安装正确
[root@localhost ~]# docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d195baed67eb: Pull complete
Digest: sha256:be06e3c4ce8780c0f87fbf66ec9b34623ba2fd14caa5559be5b593653821b814
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/
若能正常输出以上信息,则说明安装成功。
时间:2024-09 。
下载 Docker 地址 。
# 下载 Docker docker-23.0.6.tgz 为例 (当前最新版本 docker-27.2.0.tgz)
[root@localhost ~]# wget https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/docker-23.0.6.tgz
[root@localhost ~]# tar -xf docker-23.0.6.tgz
[root@localhost ~]# cp docker/* /usr/local/bin/
[root@localhost ~]# docker -v
Docker version 23.0.6, build ef23cbc
[root@localhost ~]# docker -h
# 将docker注册为 Systemd 的 service
[root@localhost ~]# cat > /etc/systemd/system/docker.service <<EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/local/bin/dockerd -H unix:///var/run/docker.sock --selinux-enabled=false --default-ulimit nofile=65536:65536
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
# 如果需要开启远程服务ExecStart属性修改为以下命令:
ExecStart=/usr/local/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --selinux-enabled=false --default-ulimit nofile=65536:65536
# -H tcp://0.0.0.0:2375 开启远程连接命令
# 添加文件可执行权限
[root@localhost ~]# chmod +x /etc/systemd/system/docker.service
# 添加国内镜像加速(每次修改需重启 docker)
[root@localhost ~]# mkdir /etc/docker
[root@localhost ~]# cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://mirror.baidubce.com",
"https://mirror.ccs.tencentyun.com",
"https://wxvmh7l6.mirror.aliyuncs.com",
"https://hub.atomgit.com",
"https://registry.docker-cn.com",
"https://mirrors.tuna.tsinghua.edu.cn",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
EOF
# 启动
[root@localhost ~]# systemctl daemon-reload && systemctl start docker
# 测试 Docker 是否安装正确
[root@localhost ~]# docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d195baed67eb: Pull complete
Digest: sha256:be06e3c4ce8780c0f87fbf66ec9b34623ba2fd14caa5559be5b593653821b814
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知识梳理及其安装使用的文章就讲到这里了,如果你想了解更多关于Docker知识梳理及其安装使用的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我听说最好不要从您系统的 Perl 版本所在的 CPAN 安装模块。我知道如何使用命令行安装模块,我只是想知道是否有办法将 CPAN 与系统核心 Perl 分开。 我应该: 下载源代码并专门为这些模块
我听说最好不要从系统的 Perl 版本所在的 CPAN 安装模块。我知道如何使用命令行安装模块,我只是想知道是否有办法将 CPAN 与系统的核心 Perl 分开。 我应该: 下载源代码并专门为这些模块
单独安装 electron 与通过 electron-builder 安装有什么区别?我正在使用 React 构建一个 Electron 应用程序,并且已经找到了一些教程。它们安装 Electron
两者安装有什么区别?我按照安装页面上的说明在全局范围内安装了 webpack,然后我转到了入门指南,据说在那里可以在本地安装 webpack-cli。 CLI = Command Line Inter
我在 OS X Yosemite 上用 PHP 安装了默认的 Apache 服务器,安装了 pear,用 brew 安装了 Solr (brew install solr),现在我正在尝试使用 PEC
我解压并编译了 Ruby 2.1 并安装了几个支持工具。 但是当我安装了 libssl-dev 时,OpenSSL 不会安装。 我在支持 openssl 时遇到这个错误: make: *** No r
我在 android studio 2.3.1 和 gradle 3.2 中设计了 2 到 3 个应用程序。当我从它运行应用程序到任何设备或模拟器时,一切都工作正常。但是当我从构建文件夹中获取该 ap
我注意到我正在读一本书提到通过 apt-get 安装 numpy 和 opencv apt-get install python-numpy python-opencv 但我可以通过以下方式在 pip
我正在尝试在 Windows 8.1 上安装 ansicon。我提取了文件并达到了我需要调用 ansicon -i 的级别。当我在 cmd 中输入此内容并运行 python 脚本时效果很好,但是当我通
我有 linux MINT 17.3 Kernel 4.4.0-81 所有更新可用。 (由于不同的原因,我无法迁移到更新版本的 ubuntu/mint) 我已经通过 PPA 安装了 FFMPEG(不是
尝试在本地运行我的应用程序时出现错误: 我只在 chrome 浏览器中收到此错误。我尝试过不同的东西,但我不确定为什么它是 Chrome 特定的。 最佳答案 我怀疑这不是 Firebase 问题,而是
这是我第一次开发 AngularJS 应用程序并使用脚手架工具 Yeoman ( http://yeoman.io/ )。我想对我的一些图标使用 fontawesome ( http://fortaw
我知道您通常“应该”$ pip install 如果包没有 brew ,但如果有一个你想安装的 python 包,你可以使用 $ pip install或 $ brew install为了?例如,通过
我正在尝试通过 RVM 安装 Ruby 1.9.3。然而,当谈到安装 RubyGems 时,我得到了这个: curl: (22) The requested URL returned error: 4
我是真正提出问题的新手,但你去吧。 我一直在尝试按照安装指南添加 dnsname: https://github.com/containers/dnsname https://github.com/c
Studio更新至0.4.0 建筑产量为“需要1.8版Gradle”;将设置设置为1.8 bin目录; 建立 “要求1.9级”;将设置设置为1.9 bin; 建立 “要求1.8级” 啊。不知道该怎么做
我刚刚注意到 kernel.org 因维护而停机。是否有使用不同镜子的不同公式?或者我可以向 Homebrew 软件添加不同的来源(如 bundler ?)? 谢谢你的帮助! 最佳答案 快速解决方法:
当我运行时: peardev install phpunit/PHPUnit 我得到以下信息: No releases available for package "pear.phpunit.de/P
服务器操作系统为Fedora 24. 64bit。 我想安装 Git 2.6.6。 所以下载源码并安装。 此服务器离线。所以我不使用“yum”。 ./configure --prefix=/usr/l
我正在尝试在我自己的服务器(操作系统:Linux Ubuntu Server 12.04)上安装 OpenEdX,但我遇到了同样的错误。谁能帮帮我? TASK: [ insights | insta
我是一名优秀的程序员,十分优秀!