Skip to Content
Kubernetes即学即用(第二版)
book

Kubernetes即学即用(第二版)

by Brendan Burns, Joe Beda, Kelsey Hightower
June 2021
Intermediate to advanced
300 pages
5h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes即学即用(第二版)
34
2
2.5 Docker
容器运行时
Kubernetes
提供了一个用于描述应用程序部署的
API
,但该
API
需要依赖容
器运行时才能建立应用程序容器,而且这一步需要用到目标操作系统上的原
生容器
API
。在
Linux
系统上,这一步就是配置
cgroup
和命名空间。容器运
行时接口(
Container Runtime Interface
CRI
)标准定义了容器运行时的接口。
CRI API
由许多不同的程序实现,包括
Docker
构建的
containerd-cri
及红帽提供的
cri-o
实现。
2.5.1
通过
Docker
运行容器
尽管在
Kubernetes
中,容器一般由每个节点上名叫
kubelet
的守护进程启动,
但通过
Docker
命令行工具学习使用容器更加容易。我们可以利用
Docker CLI
部署容器。如果想利用镜像
gcr.io/kuar-demo/kuard-amd64:blue
部署容器,
则需要运行以下命令:
$
docker run -d --name kuard \
--publish 8080:8080 \
gcr.io/kuar-demo/kuard-amd64:blue
这个命令将启动
kuard
容器,并将本地计算机上的端口
8080
映射到容器的
8080
端口上。选项
--publish
可以缩写为
-p
。因为每个容器都有自己的
IP
地址,所以这种转发很有必要,只有这样你监听的才是容器内的
localhost
而非计算机的端口。如果没有端口转发,则你的计算机就无法连接容器。选
-d
指定该容器应在后台运行(守护进程),而 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
Python数据分析

Python数据分析

Posts & Telecom Press, Ivan Idris
Python贝叶斯分析(第2版)

Python贝叶斯分析(第2版)

Posts & Telecom Press, Osvaldo Martin
Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé

Publisher Resources

ISBN: 9787519856762