docker init (original) (raw)

Description Creates Docker-related starter files for your project
Usage docker init [OPTIONS]

Requires: Docker Desktop4.27 and later

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:

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. Ifdocker-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:

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:

Option Default Description
--version Display version of the init plugin

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.

Example of selecting Go

The following example shows the prompts that appear after selecting Go and example input.

Example of selecting Node

The following example shows the prompts that appear after selecting Node and example input.

Example of selecting Python

The following example shows the prompts that appear after selecting Python and example input.

Example of selecting Rust

The following example shows the prompts that appear after selecting Rust and example input.

Example of selecting ASP.NET Core

The following example shows the prompts that appear after selecting ASP.NET Core and example input.

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.

Example of selecting Java

The following example shows the prompts that appear after selecting Java and example input.

Example of selecting Other

The following example shows the output after selecting Other.