npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

docker-api-to-compose

v0.2.0

Published

Generate docker-compose files from Docker API inspect output

Downloads

10

Readme

docker-api-to-compose

codecov Build Status Maintainability Test Coverage

Generate docker-compose files from Docker API inspect output.

Features

  • Accepts JSON data from docker API v1.37
  • Generates v3.3 docker-compose.yml files

Usage

// TODO: Is this line correct?
import { compose, getNetworkIds, getVolumeNames } from 'docker-api-to-compose';

const services = getServicesInStack('MyCoolStack');

const networkIds = getNetworkIds(services);
const networks = inspectNetworks(networkIds);

const volumeNames = getVolumeNames(services);
const volumes = inspectVolumes(volumes);

const stackFile = compose(services, networks, volumes);

Docker Compose Features

Crossed out features are not compatible with Docker Swarm.

  • [ ] ~~build~~
  • [ ] ~~cap_add, cap_drop~~
  • [ ] command
  • [ ] configs (priority)
    • [ ] Short syntax
    • [ ] Long syntax
  • [ ] ~~cgroup_parent~~
  • [ ] ~~container_name~~
  • [ ] credential_spec (3.3+)
  • [ ] deploy (3 only)
    • [ ] endpoint_mode (3.3 only)
    • [x] labels
    • [x] mode
    • [ ] placement
      • [x] constraints
      • [ ] preferences
    • [x] replicas
    • [ ] resources (priority)
    • [ ] restart_policy
    • [ ] rollback_config (3.7+)
    • [ ] update_config
  • [ ] ~~devices~~
  • [ ] ~~depends_on~~
  • [ ] dns
  • [ ] dns_search
  • [ ] tmpfs (3.6+)
  • [ ] entrypoint
  • [ ] env_file
  • [x] environment
  • [ ] expose (priority)
  • [ ] ~~external_links~~
  • [ ] extra_hosts
  • [ ] healthcheck
  • [x] image
  • [ ] init (3.7+)
  • [ ] isolation
  • [x] labels
  • [ ] ~~links~~
  • [ ] logging (priority)
  • [ ] ~~network mode~~
  • [x] networks
    • [ ] aliases
    • [ ] ~~ipv4_address, ipv6_address~~
  • [ ] pid
  • [x] ports
    • [x] Short syntax
    • [x] Long syntax (3.2+)
  • [ ] secrets (priority)
    • [ ] Short syntax
    • [ ] Long syntax
  • [ ] ~~security_opt~~
  • [ ] stop_grace_period
  • [ ] ~~stop_signal~~
  • [ ] ~~sysctls~~
  • [ ] ulimits
  • [ ] ~~userns_mode~~
  • [x] volumes
    • [x] Short syntax
      • [ ] access mode
    • [x] Long syntax (3.2+)
      • [x] type
      • [x] source
      • [x] target
      • [ ] read_only
      • [ ] bind
        • [ ] propagation
      • [ ] volume
        • [ ] nocopy
      • [ ] tmpfs
        • [ ] size
    • [ ] Caching options for volume mounts (Docker for Mac)
  • [ ] domainname, hostname, ipc, mac_address, privileged, read_only, shm_size, stdin_open, tty, user, working_dir
  • [ ] Volume configuration reference
    • [x] driver
    • [ ] driver_opts
    • [x] external (deprecated in 3.4, use name instead)
    • [ ] labels
    • [ ] name (3.4+)
  • [ ] Network configuration reference
    • [x] driver
      • [x] bridge
      • [x] overlay
      • [x] host or none
    • [ ] driver_opts
    • [ ] attachable (3.2+)
    • [ ] ~~enable_ipv6~~
    • [ ] ipam
    • [ ] internal
    • [ ] labels
    • [x] external (deprecated in 3.5, use name instead)
    • [ ] name (3.5+)
  • [ ] configs configuration reference
  • [ ] secrets configuration reference

Testing Process

The tests were developed using the following process:

  1. Writing test_x.yml
  2. docker stack deploy -c test_x.yml test_x
  3. curl --no-buffer -XGET --unix-socket /var/run/docker.sock http:/v1.37/services/test_x_MyServiceName | python -m json.tool --> test_x.json
  4. curl --no-buffer -XGET --unix-socket /var/run/docker.sock http:/v1.37/networks/text_x_default | python -m json.tool --> test_x_net.json
    • Repeat for other networks
  5. curl --no-buffer -XGET --unix-socket /var/run/docker.sock http:/v1.37/volumes/test_x_volumeName | python -m json.tool --> test_x_vol.json
    • Repeat for other volumes
  6. npm run test

A More automated method (that requires root) could be

  1. Write test_x_src.yml file to be used for deploying
  2. Write test_x.yml to be used as expected output
  3. Deploy test_x_src.yml
  4. Use a script to get related networks and services
  5. Compose stack file
  6. Compare stack files

Things that are not so great

  • Expected yml requires specific order of keys
  • Expected yml tests multiple functions