Composerize is a free open source and online tool that can generate Docker compose file from Docker run command. This is an extremely simple and useful tool for DevOps and SREs to quickly generate a plain consider “docker-componse.yml” file from a complex “docker run” command. You basically give it the full run command and then it will generate the corresponding compose file that you can run and deploy.
Docker compose files are much easier to store and maintain in my opinion and one advantage is that you do not have to remove long Docker run commands. And that is what this tool does here. You just give it the run command of Docker and then it will take care of the rest. In the next section, you will see how to use it.
How to Generate Docker Compose file from Docker Run Command?
Using this tool is quite simple. You can go to online hosted version of this tool here. The main UI looks like as shown below. Or, you can also grab its source code and then host it on your server or run it locally.
Start by typing the entire docker run command in the top box. Include all the flags, name of the image, and name of the container with other options.
As soon as you finish specifying the run command, it will instantly generate the code for the docker compose file for you. Jut scroll down a little and then you will see it there.
After the docker compose code has been generated, you simply copy it and then save it in a “docker-compose.yml” file and from now on use the following command to start the container.
sudo docker compose up -d
This is all it takes to generate Docker compose file from Docker’s run command. This is a very useful tool, and you can just bookmark it for quick access. When you are using it, you will not have to write the entire docker compose file from the scratch.
As a site reliability engineer or DevOps engineer, you often have to write Docker Compose files for various web applications. If you like to speed up the process the Composerize is the tool for you that you can try. It works pretty fast, and you just need to specify the Docker’s run command correctly with the proper syntax and all the arguments and switches.