forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_init.yaml
More file actions
297 lines (209 loc) · 10.2 KB
/
Copy pathdocker_init.yaml
File metadata and controls
297 lines (209 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
command: docker init
short: Creates Docker-related starter files for your project
long: |-
Initialize a project with the files necessary to run the project in a container.
Docker Desktop provides the `docker init` CLI command. Run `docker init` in your project directory to be walked through the creation of the following files with sensible defaults for your project:
* .dockerignore
* Dockerfile
* compose.yaml
* README.Docker.md
If any of the files already exist, a prompt appears and provides a warning
as well as giving you the option to overwrite all the files. If
`docker-compose.yaml` already exists instead of `compose.yaml`, `docker
init` can overwrite it, using `docker-compose.yaml` as the name for the
Compose file.
> [!WARNING]
>
> You can't recover overwritten files.
> To back up an existing file before selecting to overwrite it, rename the file or copy it to another directory.
After running `docker init`, you can choose one of the following templates:
* ASP.NET Core: Suitable for an ASP.NET Core application.
* Go: Suitable for a Go server application.
* Java: suitable for a Java application that uses Maven and packages as an uber jar.
* Node: Suitable for a Node server application.
* PHP with Apache: Suitable for a PHP web application.
* Python: Suitable for a Python server application.
* Rust: Suitable for a Rust server application.
* Other: General purpose starting point for containerizing your application.
After `docker init` has completed, you may need to modify the created files and tailor them to your project. Visit the following topics to learn more about the files:
* [.dockerignore](/reference/dockerfile.md#dockerignore-file)
* [Dockerfile](/reference/dockerfile.md)
* [compose.yaml](/manuals/compose/intro/compose-application-model.md)
usage: docker init [OPTIONS]
pname: docker
plink: docker.yaml
options:
- option: version
value_type: bool
default_value: "false"
description: Display version of the init plugin
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
examples: |-
### Example of running `docker init`
The following example shows the initial menu after running `docker init`. See the additional examples to view the options for each language or framework.
```console
$ docker init
Welcome to the Docker Init CLI!
This utility will walk you through creating the following files with sensible defaults for your project:
- .dockerignore
- Dockerfile
- compose.yaml
- README.Docker.md
Let's get started!
? What application platform does your project use? [Use arrows to move, type to filter]
> PHP with Apache - (detected) suitable for a PHP web application
Go - suitable for a Go server application
Java - suitable for a Java application that uses Maven and packages as an uber jar
Python - suitable for a Python server application
Node - suitable for a Node server application
Rust - suitable for a Rust server application
ASP.NET Core - suitable for an ASP.NET Core application
Other - general purpose starting point for containerizing your application
Don't see something you need? Let us know!
Quit
```
### Example of selecting Go
The following example shows the prompts that appear after selecting `Go` and example input.
```console
? What application platform does your project use? Go
? What version of Go do you want to use? 1.20
? What's the relative directory (with a leading .) of your main package? .
? What port does your server listen on? 3333
CREATED: .dockerignore
CREATED: Dockerfile
CREATED: compose.yaml
CREATED: README.Docker.md
✔ Your Docker files are ready!
Take a moment to review them and tailor them to your application.
When you're ready, start your application by running: docker compose up --build
Your application will be available at http://localhost:3333
Consult README.Docker.md for more information about using the generated files.
```
### Example of selecting Node
The following example shows the prompts that appear after selecting `Node` and example input.
```console
? What application platform does your project use? Node
? What version of Node do you want to use? 18
? Which package manager do you want to use? yarn
? Do you want to run "yarn run build" before starting your server? Yes
? What directory is your build output to? (comma-separate if multiple) output
? What command do you want to use to start the app? node index.js
? What port does your server listen on? 8000
CREATED: .dockerignore
CREATED: Dockerfile
CREATED: compose.yaml
CREATED: README.Docker.md
✔ Your Docker files are ready!
Take a moment to review them and tailor them to your application.
When you're ready, start your application by running: docker compose up --build
Your application will be available at http://localhost:8000
Consult README.Docker.md for more information about using the generated files.
```
### Example of selecting Python
The following example shows the prompts that appear after selecting `Python` and example input.
```console
? What application platform does your project use? Python
? What version of Python do you want to use? 3.8
? What port do you want your app to listen on? 8000
? What is the command to run your app (e.g., gunicorn 'myapp.example:app' --bind=0.0.0.0:8000)? python ./app.py
CREATED: .dockerignore
CREATED: Dockerfile
CREATED: compose.yaml
CREATED: README.Docker.md
✔ Your Docker files are ready!
Take a moment to review them and tailor them to your application.
When you're ready, start your application by running: docker compose up --build
Your application will be available at http://localhost:8000
Consult README.Docker.md for more information about using the generated files.
```
### Example of selecting Rust
The following example shows the prompts that appear after selecting `Rust` and example input.
```console
? What application platform does your project use? Rust
? What version of Rust do you want to use? 1.70.0
? What port does your server listen on? 8000
CREATED: .dockerignore
CREATED: Dockerfile
CREATED: compose.yaml
CREATED: README.Docker.md
✔ Your Docker files are ready!
Take a moment to review them and tailor them to your application.
When you're ready, start your application by running: docker compose up --build
Your application will be available at http://localhost:8000
Consult README.Docker.md for more information about using the generated files.
```
### Example of selecting ASP.NET Core
The following example shows the prompts that appear after selecting `ASP.NET Core` and example input.
```console
? What application platform does your project use? ASP.NET Core
? What's the name of your solution's main project? myapp
? What version of .NET do you want to use? 6.0
? What local port do you want to use to access your server? 8000
CREATED: .dockerignore
CREATED: Dockerfile
CREATED: compose.yaml
CREATED: README.Docker.md
✔ Your Docker files are ready!
Take a moment to review them and tailor them to your application.
When you're ready, start your application by running: docker compose up --build
Your application will be available at http://localhost:8000
Consult README.Docker.md for more information about using the generated files.
```
### Example of selecting PHP with Apache
The following example shows the prompts that appear after selecting `PHP with Apache` and example input. The PHP with Apache template is suitable for both pure PHP applications and applications using Composer as a dependency manager. After running `docker init`, you must manually add any PHP extensions that are required by your application to the Dockerfile.
```console
? What application platform does your project use? PHP with Apache
? What version of PHP do you want to use? 8.2
? What's the relative directory (with a leading .) for your app? ./src
? What local port do you want to use to access your server? 9000
CREATED: .dockerignore
CREATED: Dockerfile
CREATED: compose.yaml
CREATED: README.Docker.md
✔ Your Docker files are ready!
Take a moment to review them and tailor them to your application.
If your application requires specific PHP extensions, you can follow the instructions in the Dockerfile to add them.
When you're ready, start your application by running: docker compose up --build
Your application will be available at http://localhost:9000
Consult README.Docker.md for more information about using the generated files.
```
### Example of selecting Java
The following example shows the prompts that appear after selecting `Java` and example input.
```console
? What application platform does your project use? Java
? What version of Java do you want to use? 17
? What's the relative directory (with a leading .) for your app? ./src
? What port does your server listen on? 9000
CREATED: .dockerignore
CREATED: Dockerfile
CREATED: compose.yaml
CREATED: README.Docker.md
✔ Your Docker files are ready!
Take a moment to review them and tailor them to your application.
When you're ready, start your application by running: docker compose up --build
Your application will be available at http://localhost:9000
Consult README.Docker.md for more information about using the generated files.
```
### Example of selecting Other
The following example shows the output after selecting `Other`.
```console
? What application platform does your project use? Other
CREATED: .dockerignore
CREATED: Dockerfile
CREATED: compose.yaml
CREATED: README.Docker.md
✔ Your Docker files are ready!
Take a moment to review them and tailor them to your application.
When you're ready, start your application by running: docker compose up --build
Consult README.Docker.md for more information about using the generated files.
```