640 words
3 min read

Docker Init The Future of Easy Project Initialization

By · Docker Captain · CNCF Ambassador · IBM Champion
Cover image for the post 'Docker Init The Future of Easy Project Initialization'

Docker changed how we ship software, giving us a lightweight, portable, consistent runtime that works the same across different infrastructures. One of its newer additions is Docker Init, a CLI command that simplifies adding Docker to any project.

Understanding Docker Init#

The Docker Init feature should not be confused with the internally used docker-init executable, which is triggered by Docker when using the --init flag with the docker run command. The Docker Init we’re discussing here is a new feature in its beta phase that automates the creation of essential Docker-related assets like Dockerfiles, .dockerignore files, and compose.yaml files.

The Docker Init feature presently supports Go, Node, and Python, with Docker’s development team actively extending support to other languages and frameworks, including Java, Rust, and .NET. This progressive expansion promises to make Docker Init even more useful to a wide range of developers.

Working with Docker Init#

To use Docker Init, you’ll need Docker Desktop version 4.18 or later. Once this is set up, you can run the docker init command in your project’s target directory. Docker Init will detect the project’s characteristics and automatically generate the necessary Docker files. This feature is particularly valuable for developers who are new to Docker, those learning about containerization, or developers looking to integrate Docker into their existing projects.

Docker Init in Action#

Let’s take a web server written in Go as an example.

We execute the command to start the process of automatically generating the necessary files to run the application using Docker Compose:

Terminal window
docker init

Docker Init The Future of Easy Project Initialization - Step 1

Next, you need to select the programming language in which your application is written.

NOTE

In this example, we are considering an application written in Go.

Select Go and press the “Enter” button.

Docker Init The Future of Easy Project Initialization - Step 2

Now you need to specify the installed version of Go.

NOTE

In this example, we consider working with version 1.20.

You can check the installed version with the command:

Terminal window
go version

Specify the installed version of Go and press the “Enter” button.

Docker Init The Future of Easy Project Initialization - Step 3

Next, you need to select the project directory in which “main.go” is located.

NOTE

In this example, “main.go” is in the root directory of the project.

Select the project directory in which “main.go” is located and press the “Enter” button.

Docker Init The Future of Easy Project Initialization - Step 4

Now you need to specify the port on which the web server is running.

NOTE

In this example, the web server is using port 8081.

Select the port on which the web server is running and press the “Enter” button.

Docker Init The Future of Easy Project Initialization - Step 5

The necessary files to run the application using Docker Compose have been generated.

We start the web server using Docker Compose:

Terminal window
docker compose up --build

Docker Init The Future of Easy Project Initialization - Step 6

The web server has started and is using port 8081.

Now you can go to http://127.0.0.1:8081 and check if the web server is working.

Docker Init The Future of Easy Project Initialization - Step 7

The web server is running.

Docker Init The Future of Easy Project Initialization - Step 8

Benefits of Docker Init#

Docker Init plays a significant role in automating the creation of necessary Docker assets and standardizing the process across different projects. It allows developers to focus more on the development of their applications, reducing the risk of errors and inconsistencies, and thereby accelerating the adoption of Docker and containerization.

After Docker Init has completed, there may be a need to modify the created files to align them with your project requirements. In such cases, you can refer back to the Docker documentation for further information.

Conclusion#

Even in beta, Docker Init already simplifies adding Docker support to a project. By automating the creation of Docker assets, it removes one more piece of manual setup. As Docker refines and expands the feature, it’s likely to become a standard part of the toolkit.


Vladimir Mikhalev

Docker Captain  ·  CNCF Ambassador  ·  IBM Champion

The Verdict — production-tested analysis on YouTube.

The Verdict

Inconvenient truths about shipping in the AI era

Container security, platform engineering, and the agentic shift — tested in production, argued without the hype. The verdict reaches your inbox the moment there's one worth sending.

Related Posts

Same category
  1. 1
    EKS Validation on a Real AWS Account: Twenty Cents a Run, Seven Failures No Mock Saw
    DevOps & Cloud · Proving an EKS platform on a real AWS account cost twenty cents a run. Seven failed runs before it found what mocked Terraform tests and kind never could.
  2. 2
    A Partial Read Is Not a Smaller Fleet: A GitHub API Rate Limit and the Numbers That Lied for an Hour
    DevOps & Cloud · A partial read published as the whole. For an hour the profile said 24 restore scripts across 15 repositories, and the fleet had 73 across 48. Three guards now.
  3. 3
    Restore Drills on a Clean Machine — Measured RTO for 47 Stacks, 19 Seconds to 7 Minutes
    DevOps & Cloud · Restore drills that measure RTO on a machine that never ran the stack, 47 templates weekly. Every same-host restore passed. The first clean one answered 500.
  4. 4
    Mutation Testing for Infrastructure Code — 153 Planted Bugs, Four Tests That Could Not Fail
    DevOps & Cloud · Mutation testing for infrastructure code, done by hand across fifteen repositories. 153 planted bugs, and four green tests that could never have failed.

Random Posts

Random
  1. 1
    Install Gitea Using Docker Compose
    Self-Hosting · Learn how to install Gitea using Docker Compose and Traefik with free SSL from Let's Encrypt. Self-host your Git service with secure Git over SSH.
  2. 2
    Docker Scout is the Game-Changer in Container Security
    DevOps & Cloud · Docker Scout simplifies container security, giving a unified view of direct and transitive dependencies across every image layer.
  3. 3
    Install Ollama Using Docker Compose
    AI & MLOps · Deploy Ollama locally with Docker Compose and Traefik. Step-by-step guide for setting up LLMs with HTTPS, domain routing, and secure container orchestration.
  4. 4
    Configure Amazon S3 for Rocket.Chat File Sharing
    DevOps & Cloud · Step-by-step guide to integrate Amazon S3 with Rocket.Chat for secure file sharing. Learn bucket setup, IAM policies, and S3 configuration best practices.
Docker Init The Future of Easy Project Initialization
https://heyvaldemar.com/docker-init-the-future-of-easy-project-initialization/
Author
Vladimir Mikhalev
Published
2023-07-02
Updated
2026-06-16
License
CC BY-NC-SA 4.0