In this blog post I will cover about few libraries and websites which converts the docker run commands into docker-compose files.
composerize can be used from cli and website.
Using from CLI
composerize is available as npm package.
install the composerize with following command.
npm install composerize -gCode language: plaintext (plaintext)
After installing you can use it like below to produce equivalent docker-compose instructions.
composerize docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin mysql:5.7Code language: plaintext (plaintext)
The above command prints the out on command line
Instead of copying from console If you are using powershell you can redirect output to file using below command
composerize docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin mysql:5.7 > docker-compose.yml
Code language: plaintext (plaintext)
Using from website
instead of installing the library you can also use directly from website https://www.composerize.com/
I observed that using detached flag in certain places generate wrong docker-compose file
Eg : docker run –name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7
above command is a valid docker command but composerize generates wrong docker-compose file.
place your detach flag just after run to generate proper file.
docker run -d –name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:5.7
docker-compose Converter Web
docker-compose Converter Web ( dcc-web) is another website (https://bucherfa.github.io/dcc-web/) converts docker run commands to docker-compose.yml files.