GithubHelp home page GithubHelp logo

composerize

Build Status npm Follow @mark_larah ShareVB on GitHub

http://composerize.com - Turns docker run commands into docker-compose.yml files and even merge with existing docker-compose.yml!

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

See composerize --help for more options.

How to use with node.js

Make sure to install the composerize package in your project by running:

npm install composerize

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

const composerize = require('composerize');

const dockerRunCommand = 'docker run -d -p 8080:80 --name my-web-app nginx:latest';

// Convert the Docker run command to a Docker Compose configuration
const composeConfig = composerize(dockerRunCommand);

console.log(composeConfig);

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

const composerize = require('composerize');

const dockerRunCommand = 'docker run -d -p 8080:80 --name my-web-app nginx:latest';

// An existing Docker Compose configuration as a string
const existingComposeConfig = `
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 compose
const composeConfig = 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 parameter composeVersion on convertDockerRunToCompose :

  • 'v2x'
  • 'v3x'
  • 'latest'
const composerize = require('composerize');

const dockerRunCommand = 'docker run -d -p 8080:80 --name my-web-app nginx:latest';

// Convert the Docker run command to a Docker Compose configuration for 2.x
const composeConfig = composerize(dockerRunCommand, null, 'v2x');

console.log(composeConfig);

You can also choose indentation level by specifying a fourth parameter indent on convertDockerRunToCompose :

  • 'v2x'
  • 'v3x'
  • 'latest'
const composerize = require('composerize');

const dockerRunCommand = 'docker run -d -p 8080:80 --name my-web-app nginx:latest';

// Convert the Docker run command to a Docker Compose configuration for 2.x
const composeConfig = composerize(dockerRunCommand, null, 'latest', 2);

console.log(composeConfig);

Contributing

  • Clone a fork of the repo and install the project dependencies by running yarn
  • Make your changes, and build the project by running make build
  • Test your changes with make test

Maintainers

Composerize's Projects

composerize icon composerize

🏃→🎼 docker run asdlksjfksdf > docker-composerize up

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.