- Published on
Quality Docker Starters With Docker init
- Authors
- Name
- Amit Bisht
Introduction
Although it was available as a beta release since May of 2023
, last week the docker init
command became generally available
to everyone.
The initial beta release of init came with support only for Go and generic projects. The latest version, available in Docker Desktop 4.27, supports Go
, Python
, Node.js
, Rust
, ASP.NET
, PHP
, and Java
.
docker init
is a command-line utility designed to streamline the initialization of Docker resources within our project. This tool automates the creation of Dockerfiles
, Compose files
, and .dockerignore
files, tailored to the specific requirements of your project. By intelligently analyzing the project's nature, it significantly minimizes setup time and simplifies Docker configurations, empowering you to focus more on development and less on infrastructure management.
How to use it ?
It's a very straightforward command; you navigate to the root of your project and run docker init
.
It will detect the language/framework based on the files and suggest that, but you can also choose any other option. I tried it for a Node.js project. Below is the result:

Then it further narrows down to ask more questions about the project, as shown below.

Based on the inputs provided, it generated the following files:
- .dockerignore
- Dockerfile
- compose.yaml
- README.Docker.md
You can check them out here. They follow all the best practices by default.
You can find further examples with all the languages here.
Why to use it ?
It makes starting with the dockerization process is easier, more secure by default.
It eliminates the need to manually write Dockerfiles and other configuration files from scratch
, saving time and reducing the potential for errors. It's optimized for the specific type of application we are working on, ensuring that our project follows industry best practices.
There is no excuse anymore to write basic, non-optimized Dockerfiles.
Thanks for reading!