top of page
Writer's picturealexchiri

Easily dockerize an application

Updated: Mar 4

Less than a year ago, Docker released a new feature and command for Docker Desktop: docker init.


docker init is a tool that will try to bootstrap a Docker image for your existing application. It works quite nicely and can give you a good starting point for dockerizing your application.


I have a small Go project called induce-flow and I didn't get to create a Docker image for it to run. At this point, induce-flow has only one module where a simple HTTP API server is running on port 8080 and it accepts POST requests on /hook relative path.


I ran docker init it in its folder and it detected pretty much all the settings, I only had to introduce which is the relative path of my main module:

It generates the 4 files shown in the screenshot above and after I ran docker compose up --build, my application was up and running using the container docker init has generated.


In my case, the docker compose is not needed, since my little application doesn't really need anything else to run, but it can become handy later when it would need a database to run and I could create one easily locally by adding another container for the database in the compose file.


While the output it generates is a bit verbose and I might not just take what it outputs and use in Production, it is a good quick start which you can adjust later on. And it actually works!

24 views0 comments

Comments


bottom of page