Skip to content

Commit b0dd55c

Browse files
kaimalleaSEWeiTung
authored andcommitted
Update Dockerizing guide to adhere to best practice (#2293)
Update Dockerizing guide to adhere to best practice。
1 parent 6b84909 commit b0dd55c

File tree

7 files changed

+52
-58
lines changed

7 files changed

+52
-58
lines changed

locale/en/docs/guides/nodejs-docker-webapp.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ touch Dockerfile
8080
Open the `Dockerfile` in your favorite text editor
8181

8282
The first thing we need to do is define from what image we want to build from.
83-
Here we will use the latest LTS (long term support) version `8` of `node`
83+
Here we will use the latest LTS (long term support) version `10` of `node`
8484
available from the [Docker Hub](https://hub.docker.com/):
8585

8686
```docker
87-
FROM node:8
87+
FROM node:10
8888
```
8989

9090
Next we create a directory to hold the application code inside the image, this
@@ -134,17 +134,16 @@ EXPOSE 8080
134134
```
135135

136136
Last but not least, define the command to run your app using `CMD` which defines
137-
your runtime. Here we will use the basic `npm start` which will run
138-
`node server.js` to start your server:
137+
your runtime. Here we will use `node server.js` to start your server:
139138

140139
```docker
141-
CMD [ "npm", "start" ]
140+
CMD [ "node", "server.js" ]
142141
```
143142

144143
Your `Dockerfile` should now look like this:
145144

146145
```docker
147-
FROM node:8
146+
FROM node:10
148147
149148
# Create app directory
150149
WORKDIR /usr/src/app
@@ -162,7 +161,7 @@ RUN npm install
162161
COPY . .
163162
164163
EXPOSE 8080
165-
CMD [ "npm", "start" ]
164+
CMD [ "node", "server.js" ]
166165
```
167166

168167
## .dockerignore file
@@ -195,7 +194,7 @@ $ docker images
195194

196195
# Example
197196
REPOSITORY TAG ID CREATED
198-
node 8 1934b0b038d1 5 days ago
197+
node 10 1934b0b038d1 5 days ago
199198
<your username>/node-web-app latest d64d3505b0d2 1 minute ago
200199
```
201200

locale/fa/docs/guides/nodejs-docker-webapp.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ touch Dockerfile
8282
Open the `Dockerfile` in your favorite text editor
8383

8484
The first thing we need to do is define from what image we want to build from.
85-
Here we will use the latest LTS (long term support) version `8` of `node`
85+
Here we will use the latest LTS (long term support) version `10` of `node`
8686
available from the [Docker Hub](https://hub.docker.com/):
8787

8888
```docker
89-
FROM node:8
89+
FROM node:10
9090
```
9191

9292
Next we create a directory to hold the application code inside the image, this
@@ -134,17 +134,16 @@ EXPOSE 8080
134134
```
135135

136136
Last but not least, define the command to run your app using `CMD` which defines
137-
your runtime. Here we will use the basic `npm start` which will run
138-
`node server.js` to start your server:
137+
your runtime. Here we will use `node server.js` to start your server:
139138

140139
```docker
141-
CMD [ "npm", "start" ]
140+
CMD [ "node", "server.js" ]
142141
```
143142

144143
Your `Dockerfile` should now look like this:
145144

146145
```docker
147-
FROM node:8
146+
FROM node:10
148147
149148
# Create app directory
150149
WORKDIR /usr/src/app
@@ -162,7 +161,7 @@ RUN npm install
162161
COPY . .
163162
164163
EXPOSE 8080
165-
CMD [ "npm", "start" ]
164+
CMD [ "node", "server.js" ]
166165
```
167166

168167
## .dockerignore file

locale/it/docs/guides/nodejs-docker-webapp.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ touch Dockerfile
8282
Open the `Dockerfile` in your favorite text editor
8383

8484
The first thing we need to do is define from what image we want to build from.
85-
Here we will use the latest LTS (long term support) version `8` of `node`
85+
Here we will use the latest LTS (long term support) version `10` of `node`
8686
available from the [Docker Hub](https://hub.docker.com/):
8787

8888
```docker
89-
FROM node:8
89+
FROM node:10
9090
```
9191

9292
Next we create a directory to hold the application code inside the image, this
@@ -134,17 +134,16 @@ EXPOSE 8080
134134
```
135135

136136
Last but not least, define the command to run your app using `CMD` which defines
137-
your runtime. Here we will use the basic `npm start` which will run
138-
`node server.js` to start your server:
137+
your runtime. Here we will use `node server.js` to start your server:
139138

140139
```docker
141-
CMD [ "npm", "start" ]
140+
CMD [ "node", "server.js" ]
142141
```
143142

144143
Your `Dockerfile` should now look like this:
145144

146145
```docker
147-
FROM node:8
146+
FROM node:10
148147
149148
# Create app directory
150149
WORKDIR /usr/src/app
@@ -162,7 +161,7 @@ RUN npm install
162161
COPY . .
163162
164163
EXPOSE 8080
165-
CMD [ "npm", "start" ]
164+
CMD [ "node", "server.js" ]
166165
```
167166

168167
## .dockerignore file

locale/ja/docs/guides/nodejs-docker-webapp.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ touch Dockerfile
155155
Open the `Dockerfile` in your favorite text editor
156156
157157
The first thing we need to do is define from what image we want to build from.
158-
Here we will use the latest LTS (long term support) version `8` of `node`
158+
Here we will use the latest LTS (long term support) version `10` of `node`
159159
available from the [Docker Hub](https://hub.docker.com/):
160160
161161
```docker
162-
FROM node:8
162+
FROM node:10
163163
```
164164
165165
Next we create a directory to hold the application code inside the image, this
@@ -207,17 +207,16 @@ EXPOSE 8080
207207
```
208208
209209
Last but not least, define the command to run your app using `CMD` which defines
210-
your runtime. Here we will use the basic `npm start` which will run
211-
`node server.js` to start your server:
210+
your runtime. Here we will use `node server.js` to start your server:
212211
213212
```docker
214-
CMD [ "npm", "start" ]
213+
CMD [ "node", "server.js" ]
215214
```
216215
217216
Your `Dockerfile` should now look like this:
218217
219218
```docker
220-
FROM node:8
219+
FROM node:10
221220
222221
# Create app directory
223222
WORKDIR /usr/src/app
@@ -235,7 +234,7 @@ RUN npm install
235234
COPY . .
236235
237236
EXPOSE 8080
238-
CMD [ "npm", "start" ]
237+
CMD [ "node", "server.js" ]
239238
```
240239
241240
-->
@@ -251,10 +250,10 @@ touch Dockerfile
251250

252251
最初にしなければならないことは、どのイメージから構築したいかを定義することです。
253252
ここでは[Docker Hub](https://hub.docker.com/)から入手できる
254-
`node` の最新の LTS (long term support) バージョン `8` を使います。
253+
`node` の最新の LTS (long term support) バージョン `10` を使います。
255254

256255
```docker
257-
FROM node:8
256+
FROM node:10
258257
```
259258

260259
次に、イメージ内にアプリケーションコードを入れるディレクトリを作成します。
@@ -306,13 +305,13 @@ EXPOSE 8080
306305
基本的な `npm start` を使います:
307306

308307
```docker
309-
CMD [ "npm", "start" ]
308+
CMD [ "node", "server.js" ]
310309
```
311310

312311
`Dockerfile` はこのようになっているはずです。
313312

314313
```docker
315-
FROM node:8
314+
FROM node:10
316315
317316
# アプリケーションディレクトリを作成する
318317
WORKDIR /usr/src/app
@@ -330,7 +329,7 @@ RUN npm install
330329
COPY . .
331330
332331
EXPOSE 8080
333-
CMD [ "npm", "start" ]
332+
CMD [ "node", "server.js" ]
334333
```
335334

336335
<!--

locale/ko/docs/guides/nodejs-docker-webapp.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ touch Dockerfile
151151
Open the `Dockerfile` in your favorite text editor
152152
153153
The first thing we need to do is define from what image we want to build from.
154-
Here we will use the latest LTS (long term support) version `8` of `node`
154+
Here we will use the latest LTS (long term support) version `10` of `node`
155155
available from the [Docker Hub](https://hub.docker.com/):
156156
157157
```docker
158-
FROM node:8
158+
FROM node:10
159159
```
160160
-->
161161

@@ -171,10 +171,10 @@ touch Dockerfile
171171

172172
가장 먼저 해야 할 것은 어떤 이미지를 사용해서 빌드할 것인지를 정의하는 것입니다. 여기서는
173173
[Docker Hub](https://hub.docker.com/)에 있는
174-
`node`의 최신 LTS(장기 지원) 버전인 `8`을 사용할 것입니다.
174+
`node`의 최신 LTS(장기 지원) 버전인 `10`을 사용할 것입니다.
175175

176176
```docker
177-
FROM node:8
177+
FROM node:10
178178
```
179179

180180
<!--
@@ -273,17 +273,16 @@ EXPOSE 8080
273273

274274
<!--
275275
Last but not least, define the command to run your app using `CMD` which defines
276-
your runtime. Here we will use the basic `npm start` which will run
277-
`node server.js` to start your server:
276+
your runtime. Here we will use `node server.js` to start your server:
278277
279278
```docker
280-
CMD [ "npm", "start" ]
279+
CMD [ "node", "server.js" ]
281280
```
282281
283282
Your `Dockerfile` should now look like this:
284283
285284
```docker
286-
FROM node:8
285+
FROM node:10
287286
288287
# Create app directory
289288
WORKDIR /usr/src/app
@@ -301,21 +300,21 @@ RUN npm install
301300
COPY . .
302301
303302
EXPOSE 8080
304-
CMD [ "npm", "start" ]
303+
CMD [ "node", "server.js" ]
305304
```
306305
-->
307306

308307
마지막으로 런타임을 정의하는 `CMD`로 앱을 실행하는 중요 명령어를 정의해야 합니다.
309308
여기서는 서버를 구동하도록 `node server.js`을 실행하는 기본 `npm start`을 사용할 것입니다.
310309

311310
```docker
312-
CMD [ "npm", "start" ]
311+
CMD [ "node", "server.js" ]
313312
```
314313

315314
`Dockerfile`은 다음과 같아야 합니다.
316315

317316
```docker
318-
FROM node:8
317+
FROM node:10
319318
320319
# 앱 디렉터리 생성
321320
WORKDIR /usr/src/app
@@ -333,7 +332,7 @@ RUN npm install
333332
COPY . .
334333
335334
EXPOSE 8080
336-
CMD [ "npm", "start" ]
335+
CMD [ "node", "server.js" ]
337336
```
338337

339338
<!--

locale/ru/docs/guides/nodejs-docker-webapp.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ touch Dockerfile
8282
Open the `Dockerfile` in your favorite text editor
8383

8484
The first thing we need to do is define from what image we want to build from.
85-
Here we will use the latest LTS (long term support) version `8` of `node`
85+
Here we will use the latest LTS (long term support) version `10` of `node`
8686
available from the [Docker Hub](https://hub.docker.com/):
8787

8888
```docker
89-
FROM node:8
89+
FROM node:10
9090
```
9191

9292
Next we create a directory to hold the application code inside the image, this
@@ -136,17 +136,16 @@ EXPOSE 8080
136136
```
137137

138138
Last but not least, define the command to run your app using `CMD` which defines
139-
your runtime. Here we will use the basic `npm start` which will run
140-
`node server.js` to start your server:
139+
your runtime. Here we will use `node server.js` to start your server:
141140

142141
```docker
143-
CMD [ "npm", "start" ]
142+
CMD [ "node", "server.js" ]
144143
```
145144

146145
Your `Dockerfile` should now look like this:
147146

148147
```docker
149-
FROM node:8
148+
FROM node:10
150149
151150
# Create app directory
152151
WORKDIR /usr/src/app
@@ -164,7 +163,7 @@ RUN npm install
164163
COPY . .
165164
166165
EXPOSE 8080
167-
CMD [ "npm", "start" ]
166+
CMD [ "node", "server.js" ]
168167
```
169168

170169
## .dockerignore file

locale/zh-cn/docs/guides/nodejs-docker-webapp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ touch Dockerfile
6767

6868
用你最喜欢的文本编辑器打开这个 `Dockerfile`
6969

70-
我们要做的第一件事是定义我们需要从哪个镜像进行构建。这里我们将使用最新的 LTS(长期服务器支持版),`Node` 的版本号为 `8`。你可以从 [Docker 站点](https://hub.docker.com/) 获取相关镜像:
70+
我们要做的第一件事是定义我们需要从哪个镜像进行构建。这里我们将使用最新的 LTS(长期服务器支持版),`Node` 的版本号为 `10`。你可以从 [Docker 站点](https://hub.docker.com/) 获取相关镜像:
7171

7272
```docker
73-
FROM node:8
73+
FROM node:10
7474
```
7575

7676
下一步在镜像中创建一个文件夹存放应用程序代码,这将是你的应用程序工作目录:
@@ -112,13 +112,13 @@ EXPOSE 8080
112112
最后但同样重要的事是,使用定义运行时的 `CMD` 定义命令来运行应用程序。这里我们使用最简单的 `npm start` 命令,它将运行 `node server.js` 启动你的服务器:
113113

114114
```docker
115-
CMD [ "npm", "start" ]
115+
CMD [ "node", "server.js" ]
116116
```
117117

118118
你的 `Dockerfile` 现在看上去是这个样子:
119119

120120
```docker
121-
FROM node:8
121+
FROM node:10
122122
123123
# Create app directory
124124
WORKDIR /usr/src/app
@@ -136,7 +136,7 @@ RUN npm install
136136
COPY . .
137137
138138
EXPOSE 8080
139-
CMD [ "npm", "start" ]
139+
CMD [ "node", "server.js" ]
140140
```
141141

142142
## .dockerignore 文件

0 commit comments

Comments
 (0)