Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🏃→🎼 docker run asdlksjfksdf > docker-composerize up

License

NotificationsYou must be signed in to change notification settings

composerize/composerize

Repository files navigation

Build StatusnpmFollow @mark_larahShareVB on GitHub

http://composerize.com - Turnsdocker run commands intocompose.yaml files and even merge with existingcompose.yaml!

Looking for the reverse :http://decomposerize.com /Decomposerize

Want to convert from Docker compose file formats :http://composeverter.com /Composeverter

Demo

CLI

composerize can be run in the cli.

npm install composerize -g to install, and run as such:

$ composerize docker run -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --restart always --log-opt max-size=1g nginx

Seecomposerize --help for more options.

Docker image

A dockker image of composerize, decomposerize and composeverter websites is available here:https://github.com/Oaklight/composerize-minimal/blob/master/README_en.md (thanks to @Oaklight)

How to use with node.js

Make sure to install thecomposerize package in your project by running:

npm install composerize

With the following code, you can easily integrateComposerize into your Node.js project and generate Docker Compose configurations from Docker run commands.

constcomposerize=require('composerize');constdockerRunCommand='docker run -d -p 8080:80 --name my-web-app nginx:latest';// Convert the Docker run command to a Docker Compose configurationconstcomposeConfig=composerize(dockerRunCommand);console.log(composeConfig);

You can also merge docker run command(s) with an existing Docker Compose file content :

constcomposerize=require('composerize');constdockerRunCommand='docker run -d -p 8080:80 --name my-web-app nginx:latest';// An existing Docker Compose configuration as a stringconstexistingComposeConfig=`version: '3'services:  existing-service:    image: my-existing-image:latest    ports:      - '8000:80'`;// Convert the Docker run command to a Docker Compose configuration and merge with provided docker composeconstcomposeConfig=composerize(dockerRunCommand,existingComposeConfig);console.log(composeConfig);

You can also choose which version of Docker compose V2, you target : 2.x, 3.x or Common Specification by specifying a third parametercomposeVersion onconvertDockerRunToCompose :

  • 'v2x'
  • 'v3x'
  • 'latest'
constcomposerize=require('composerize');constdockerRunCommand='docker run -d -p 8080:80 --name my-web-app nginx:latest';// Convert the Docker run command to a Docker Compose configuration for 2.xconstcomposeConfig=composerize(dockerRunCommand,null,'v2x');console.log(composeConfig);

You can also choose indentation level by specifying a fourth parameterindent onconvertDockerRunToCompose :

  • 'v2x'
  • 'v3x'
  • 'latest'
constcomposerize=require('composerize');constdockerRunCommand='docker run -d -p 8080:80 --name my-web-app nginx:latest';// Convert the Docker run command to a Docker Compose configuration for 2.xconstcomposeConfig=composerize(dockerRunCommand,null,'latest',2);console.log(composeConfig);

Contributing

  • Clone a fork of the repo and install the project dependencies by runningyarn
  • Make your changes, and build the project by runningmake build
  • Test your changes withmake test

Maintainers

About

🏃→🎼 docker run asdlksjfksdf > docker-composerize up

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp