@@ -20,22 +20,19 @@ running Container.
20
20
<!--
21
21
## Getting a shell to a Container
22
22
-->
23
-
24
23
## 获取容器的 Shell
25
24
26
25
<!--
27
26
In this exercise, you create a Pod that has one Container. The Container
28
27
runs the nginx image. Here is the configuration file for the Pod:
29
28
-->
30
-
31
29
在本练习中,你将创建包含一个容器的 Pod。容器运行 nginx 镜像。下面是 Pod 的配置文件:
32
30
33
31
{{< codenew file="application/shell-demo.yaml" >}}
34
32
35
33
<!--
36
34
Create the Pod:
37
35
-->
38
-
39
36
创建 Pod:
40
37
41
38
``` shell
@@ -45,7 +42,6 @@ kubectl create -f https://k8s.io/examples/application/shell-demo.yaml
45
42
<!--
46
43
Verify that the Container is running:
47
44
-->
48
-
49
45
检查容器是否运行正常:
50
46
51
47
``` shell
@@ -55,7 +51,6 @@ kubectl get pod shell-demo
55
51
<!--
56
52
Get a shell to the running Container:
57
53
-->
58
-
59
54
获取正在运行容器的 Shell:
60
55
61
56
``` shell
@@ -72,7 +67,6 @@ The double dash symbol "--" is used to separate the arguments you want to pass t
72
67
<!--
73
68
In your shell, list the root directory:
74
69
-->
75
-
76
70
在 shell 中,打印根目录:
77
71
78
72
``` shell
@@ -83,7 +77,6 @@ root@shell-demo:/# ls /
83
77
In your shell, experiment with other commands. Here are
84
78
some examples:
85
79
-->
86
-
87
80
在 shell 中,实验其他命令。下面是一些示例:
88
81
89
82
``` shell
@@ -103,22 +96,19 @@ root@shell-demo:/# ps aux | grep nginx
103
96
<!--
104
97
## Writing the root page for nginx
105
98
-->
106
-
107
99
## 编写 nginx 的根页面
108
100
109
101
<!--
110
102
Look again at the configuration file for your Pod. The Pod
111
103
has an `emptyDir` volume, and the Container mounts the volume
112
104
at `/usr/share/nginx/html`.
113
105
-->
114
-
115
- 在看一下 Pod 的配置文件。该 Pod 有个 ` emptyDir ` 卷,容器将该卷挂载到了 ` /usr/share/nginx/html ` 。
106
+ 再看一下 Pod 的配置文件。该 Pod 有个 ` emptyDir ` 卷,容器将该卷挂载到了 ` /usr/share/nginx/html ` 。
116
107
117
108
<!--
118
109
In your shell, create an `index.html` file in the `/usr/share/nginx/html`
119
110
directory:
120
111
-->
121
-
122
112
在 shell 中,在 ` /usr/share/nginx/html ` 目录创建一个 ` index.html ` 文件:
123
113
124
114
``` shell
@@ -128,7 +118,6 @@ root@shell-demo:/# echo Hello shell demo > /usr/share/nginx/html/index.html
128
118
<!--
129
119
In your shell, send a GET request to the nginx server:
130
120
-->
131
-
132
121
在 shell 中,向 nginx 服务器发送 GET 请求:
133
122
134
123
``` shell
@@ -140,7 +129,6 @@ root@shell-demo:/# curl localhost
140
129
<!--
141
130
The output shows the text that you wrote to the `index.html` file:
142
131
-->
143
-
144
132
输出结果显示了你在 ` index.html ` 中写入的文本。
145
133
146
134
``` shell
@@ -150,20 +138,17 @@ Hello shell demo
150
138
<!--
151
139
When you are finished with your shell, enter `exit`.
152
140
-->
153
-
154
141
当用完 shell 后,输入 ` exit ` 退出。
155
142
156
143
<!--
157
144
## Running individual commands in a Container
158
145
-->
159
-
160
146
## 在容器中运行单个命令
161
147
162
148
<!--
163
149
In an ordinary command window, not your shell, list the environment
164
150
variables in the running Container:
165
151
-->
166
-
167
152
在普通的命令窗口(而不是 shell)中,打印环境运行容器中的变量:
168
153
169
154
``` shell
@@ -173,7 +158,6 @@ kubectl exec shell-demo env
173
158
<!--
174
159
Experiment running other commands. Here are some examples:
175
160
-->
176
-
177
161
实验运行其他命令。下面是一些示例:
178
162
179
163
``` shell
@@ -187,7 +171,6 @@ kubectl exec shell-demo cat /proc/1/mounts
187
171
<!--
188
172
## Opening a shell when a Pod has more than one Container
189
173
-->
190
-
191
174
## 当 Pod 包含多个容器时打开 shell
192
175
193
176
<!--
@@ -197,9 +180,8 @@ suppose you have a Pod named my-pod, and the Pod has two containers
197
180
named main-app and helper-app. The following command would open a
198
181
shell to the main-app Container.
199
182
-->
200
-
201
183
如果 Pod 有多个容器,` --container ` 或者 ` -c ` 可以在 ` kubectl exec ` 命令中指定容器。
202
- 例如,您有个名为 my-pod 的容器 ,该 Pod 有两个容器分别为 main-app 和 healper-app。
184
+ 例如,你有个名为 my-pod 的 Pod ,该 Pod 有两个容器分别为 main-app 和 healper-app。
203
185
下面的命令将会打开一个 shell 访问 main-app 容器。
204
186
205
187
``` shell
0 commit comments