Skip to content

Commit b013a56

Browse files
committed
[zh] updated docker-cli-to-kubectl.md
1 parent 1db4807 commit b013a56

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

content/zh-cn/docs/reference/kubectl/docker-cli-to-kubectl.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ You can use the Kubernetes command line tool `kubectl` to interact with the API
1818
则使用 kubectl 非常简单。但是,Docker 命令和 kubectl 命令之间有一些区别。以下显示了 Docker 子命令,
1919
并描述了等效的 `kubectl` 命令。
2020

21-
2221
<!-- body -->
2322
## docker run
2423

@@ -30,7 +29,7 @@ To run an nginx Deployment and expose the Deployment, see [kubectl create deploy
3029
<!--
3130
docker:
3231
-->
33-
使用 docker 命令:
32+
使用 Docker 命令:
3433

3534
```shell
3635
docker run -d --restart=always -e DOMAIN=cluster --name nginx-app -p 80:80 nginx
@@ -67,7 +66,7 @@ deployment.apps/nginx-app created
6766
```
6867

6968
```shell
70-
# add env to nginx-app
69+
# 添加 env nginx-app
7170
kubectl set env deployment/nginx-app DOMAIN=cluster
7271
```
7372
```
@@ -99,9 +98,9 @@ service "nginx-http" exposed
9998
By using kubectl, you can create a [Deployment](/docs/concepts/workloads/controllers/deployment/) to ensure that N pods are running nginx, where N is the number of replicas stated in the spec and defaults to 1. You can also create a [service](/docs/concepts/services-networking/service/) with a selector that matches the pod labels. For more information, see [Use a Service to Access an Application in a Cluster](/docs/tasks/access-application-cluster/service-access-application-cluster).
10099
-->
101100
在 kubectl 命令中,我们创建了一个 [Deployment](/zh-cn/docs/concepts/workloads/controllers/deployment/)
102-
这将保证有 N 个运行 nginx 的 Pod(N 代表 spec 中声明的 replica 数,默认为 1)。
103-
我们还创建了一个 [service](/zh-cn/docs/concepts/services-networking/service/)其选择器与容器标签匹配
104-
查看[使用服务访问集群中的应用程序](/zh-cn/docs/tasks/access-application-cluster/service-access-application-cluster) 获取更多信息。
101+
这将保证有 N 个运行 nginx 的 Pod(N 代表 spec 中声明的副本数,默认为 1)。
102+
我们还创建了一个 [service](/zh-cn/docs/concepts/services-networking/service/)其选择算符与容器标签匹配
103+
查看[使用服务访问集群中的应用程序](/zh-cn/docs/tasks/access-application-cluster/service-access-application-cluster)获取更多信息。
105104

106105
<!--
107106
By default images run in the background, similar to `docker run -d ...`. To run things in the foreground, use [`kubectl run`](/docs/reference/generated/kubectl/kubectl-commands/#run) to create pod:
@@ -117,7 +116,7 @@ kubectl run [-i] [--tty] --attach <name> --image=<image>
117116
Unlike `docker run ...`, if you specify `--attach`, then you attach `stdin`, `stdout` and `stderr`. You cannot control which streams are attached (`docker -a ...`).
118117
To detach from the container, you can type the escape sequence Ctrl+P followed by Ctrl+Q.
119118
-->
120-
`docker run ...` 不同的是,如果指定了 `--attach`,我们将连接到 `stdin``stdout``stderr`
119+
`docker run ...` 不同的是,如果指定了 `--attach`,我们将连接到 `stdin``stdout``stderr`
121120
而不能控制具体连接到哪个输出流(`docker -a ...`)。要从容器中退出,可以输入 Ctrl + P,然后按 Ctrl + Q。
122121

123122
<!--
@@ -137,8 +136,8 @@ To list what is currently running, see [kubectl get](/docs/reference/generated/k
137136

138137
<!--
139138
docker:
140-
-->
141-
使用 docker 命令:
139+
-->
140+
使用 Docker 命令:
142141

143142
```shell
144143
docker ps -a
@@ -174,7 +173,7 @@ To attach a process that is already running in a container, see [kubectl attach]
174173
<!--
175174
docker:
176175
-->
177-
使用 docker 命令:
176+
使用 Docker 命令:
178177

179178
```shell
180179
docker ps
@@ -219,7 +218,7 @@ To execute a command in a container, see [kubectl exec](/docs/reference/generate
219218
<!--
220219
docker:
221220
-->
222-
使用 docker 命令:
221+
使用 Docker 命令:
223222

224223
```shell
225224
docker ps
@@ -263,7 +262,7 @@ To use interactive commands.
263262
<!--
264263
docker:
265264
-->
266-
使用 docker 命令:
265+
使用 Docker 命令:
267266

268267
```shell
269268
docker exec -ti 55c103fa1296 /bin/sh
@@ -289,11 +288,10 @@ To follow stdout/stderr of a process that is running, see [kubectl logs](/docs/r
289288
-->
290289
如何查看运行中进程的 stdout/stderr?查看 [kubectl logs](/docs/reference/generated/kubectl/kubectl-commands/#logs)
291290

292-
293291
<!--
294292
docker:
295293
-->
296-
使用 docker 命令:
294+
使用 Docker 命令:
297295

298296
```shell
299297
docker logs -f a9e
@@ -321,7 +319,7 @@ There is a slight difference between pods and containers; by default pods do not
321319
-->
322320
现在是时候提一下 Pod 和容器之间的细微差别了;默认情况下如果 Pod 中的进程退出 Pod 也不会终止,
323321
相反它将会重启该进程。这类似于 docker run 时的 `--restart=always` 选项,这是主要差别。
324-
docker 中,进程的每个调用的输出都是被连接起来的,但是对于 Kubernetes,每个调用都是分开的。
322+
Docker 中,进程的每个调用的输出都是被连接起来的,但是对于 Kubernetes,每个调用都是分开的。
325323
要查看以前在 Kubernetes 中执行的输出,请执行以下操作:
326324

327325
```shell
@@ -337,7 +335,10 @@ For more information, see [Logging Architecture](/docs/concepts/cluster-administ
337335
-->
338336
查看[日志架构](/zh-cn/docs/concepts/cluster-administration/logging/)获取更多信息。
339337

338+
<!--
340339
## docker stop and docker rm
340+
-->
341+
## docker stop 和 docker rm {#docker-stop-and-docker-rm}
341342

342343
<!--
343344
To stop and delete a running process, see [kubectl delete](/docs/reference/generated/kubectl/kubectl-commands/#delete).
@@ -347,7 +348,7 @@ To stop and delete a running process, see [kubectl delete](/docs/reference/gener
347348
<!--
348349
docker:
349350
-->
350-
使用 docker 命令:
351+
使用 Docker 命令:
351352

352353
```shell
353354
docker ps
@@ -400,7 +401,7 @@ deployment "nginx-app" deleted
400401

401402
```shell
402403
kubectl get po -l app=nginx-app
403-
# Return nothing
404+
# 什么都没有返回
404405
```
405406

406407
{{< note >}}
@@ -429,7 +430,7 @@ To get the version of client and server, see [kubectl version](/docs/reference/g
429430
<!--
430431
docker:
431432
-->
432-
使用 docker 命令:
433+
使用 Docker 命令:
433434

434435
```shell
435436
docker version
@@ -470,7 +471,7 @@ To get miscellaneous information about the environment and configuration, see [k
470471
<!--
471472
docker:
472473
-->
473-
使用 docker 命令:
474+
使用 Docker 命令:
474475

475476
```shell
476477
docker info

0 commit comments

Comments
 (0)