Merge pull request #33698 from my-git9/mygit15

[zh] adjust get-shell-running-container.md
pull/33756/head
Kubernetes Prow Robot 2022-05-15 17:56:16 -07:00 committed by GitHub
commit 498bcd3d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 20 deletions

View File

@ -20,14 +20,12 @@ running Container.
<!--
## Getting a shell to a Container
-->
## 获取容器的 Shell
<!--
In this exercise, you create a Pod that has one Container. The Container
runs the nginx image. Here is the configuration file for the Pod:
-->
在本练习中,你将创建包含一个容器的 Pod。容器运行 nginx 镜像。下面是 Pod 的配置文件:
{{< codenew file="application/shell-demo.yaml" >}}
@ -35,7 +33,6 @@ runs the nginx image. Here is the configuration file for the Pod:
<!--
Create the Pod:
-->
创建 Pod
```shell
@ -45,7 +42,6 @@ kubectl create -f https://k8s.io/examples/application/shell-demo.yaml
<!--
Verify that the Container is running:
-->
检查容器是否运行正常:
```shell
@ -55,7 +51,6 @@ kubectl get pod shell-demo
<!--
Get a shell to the running Container:
-->
获取正在运行容器的 Shell
```shell
@ -72,7 +67,6 @@ The double dash symbol "--" is used to separate the arguments you want to pass t
<!--
In your shell, list the root directory:
-->
在 shell 中,打印根目录:
```shell
@ -83,7 +77,6 @@ root@shell-demo:/# ls /
In your shell, experiment with other commands. Here are
some examples:
-->
在 shell 中,实验其他命令。下面是一些示例:
```shell
@ -103,7 +96,6 @@ root@shell-demo:/# ps aux | grep nginx
<!--
## Writing the root page for nginx
-->
## 编写 nginx 的根页面
<!--
@ -111,14 +103,12 @@ Look again at the configuration file for your Pod. The Pod
has an `emptyDir` volume, and the Container mounts the volume
at `/usr/share/nginx/html`.
-->
在看一下 Pod 的配置文件。该 Pod 有个 `emptyDir` 卷,容器将该卷挂载到了 `/usr/share/nginx/html`
再看一下 Pod 的配置文件。该 Pod 有个 `emptyDir` 卷,容器将该卷挂载到了 `/usr/share/nginx/html`
<!--
In your shell, create an `index.html` file in the `/usr/share/nginx/html`
directory:
-->
在 shell 中,在 `/usr/share/nginx/html` 目录创建一个 `index.html` 文件:
```shell
@ -128,7 +118,6 @@ root@shell-demo:/# echo Hello shell demo > /usr/share/nginx/html/index.html
<!--
In your shell, send a GET request to the nginx server:
-->
在 shell 中,向 nginx 服务器发送 GET 请求:
```shell
@ -140,7 +129,6 @@ root@shell-demo:/# curl localhost
<!--
The output shows the text that you wrote to the `index.html` file:
-->
输出结果显示了你在 `index.html` 中写入的文本。
```shell
@ -150,20 +138,17 @@ Hello shell demo
<!--
When you are finished with your shell, enter `exit`.
-->
当用完 shell 后,输入 `exit` 退出。
<!--
## Running individual commands in a Container
-->
## 在容器中运行单个命令
<!--
In an ordinary command window, not your shell, list the environment
variables in the running Container:
-->
在普通的命令窗口(而不是 shell打印环境运行容器中的变量
```shell
@ -173,7 +158,6 @@ kubectl exec shell-demo env
<!--
Experiment running other commands. Here are some examples:
-->
实验运行其他命令。下面是一些示例:
```shell
@ -187,7 +171,6 @@ kubectl exec shell-demo cat /proc/1/mounts
<!--
## Opening a shell when a Pod has more than one Container
-->
## 当 Pod 包含多个容器时打开 shell
<!--
@ -197,9 +180,8 @@ suppose you have a Pod named my-pod, and the Pod has two containers
named main-app and helper-app. The following command would open a
shell to the main-app Container.
-->
如果 Pod 有多个容器,`--container` 或者 `-c` 可以在 `kubectl exec` 命令中指定容器。
例如,您有个名为 my-pod 的容器,该 Pod 有两个容器分别为 main-app 和 healper-app。
例如,你有个名为 my-pod 的 Pod,该 Pod 有两个容器分别为 main-app 和 healper-app。
下面的命令将会打开一个 shell 访问 main-app 容器。
```shell