• Stars
    star
    1,277
  • Rank 35,904 (Top 0.8 %)
  • Language
    Python
  • Created over 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate a docker-compose yaml definition from a running container

docker-autocompose

Generates a docker-compose yaml definition from a docker container.

Required Modules:

Example Usage:

sudo python autocompose.py <container-name-or-id>

Generate a compose file for multiple containers together:

sudo python autocompose.py apache-test mysql-test

The script defaults to outputting to compose file version 3, but use "-v 1" to output to version 1:

sudo python autocompose.py -v 1 apache-test

Outputs a docker-compose compatible yaml structure:

docker-compose reference

docker-compose yaml file specification

While experimenting with various docker containers from the Hub, I realized that I'd started several containers with complex options for volumes, ports, environment variables, etc. and there was no way I could remember all those commands without referencing the Hub page for each image if I needed to delete and re-create the container (for updates, or if something broke).

With this tool, I can easily generate docker-compose files for managing the containers that I've set up manually.

Docker Usage

You can use this tool from a docker container by either cloning this repo and building the image or using the automatically generated image on GitHub

Pull the image from GitHub (supports both x86 and ARM)

docker pull ghcr.io/red5d/docker-autocompose:latest

Use the new image to generate a docker-compose file from a running container or a list of space-separated container names or ids:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose <container-name-or-id> <additional-names-or-ids>...

To print out all containers in a docker-compose format:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose $(docker ps -aq)

Contributing

When making changes, please validate the output from the script by writing it to a file (docker-compose.yml or docker-compose.yaml) and running "docker-compose config" in the same folder with it to ensure that the resulting compose file will be accepted by docker-compose.

More Repositories

1

pushbullet-bash

Bash interface to the PushBullet API
Shell
228
star
2

edlkit

Python tools to create, tweak, and apply EDL file edits to video files.
Python
37
star
3

ztadmin

A scriptable interface to ZeroTier One's administration API.
Python
21
star
4

sonoff-mqtt

Controlling Sonoff esp8266 devices through MQTT
Lua
8
star
5

hivefs

A FUSE filesystem for the Hive.im cloud storage service. - Reference only. The Hive.im service shut down.
Python
6
star
6

security-topics-tree

A tree diagram of Computer Security topics.
5
star
7

Linux-on-Chuwi-HiBook-Pro

Linux setup and driver information for running Linux on the Chuwi HiBook Pro
Shell
5
star
8

micropython-modules

Utility and GUI modules for MicroPython and the M5Stack dev kit
Python
5
star
9

contextcommands

A tool for running commands based on the context from the previous command.
Python
4
star
10

nexpose-tools

Tools and monitoring scripts for Nexpose
Ruby
4
star
11

mycroft-docker

Dockerized Mycroft-core
Shell
4
star
12

nse-scripts

My Nmap scripts for the Nmap Scripting Engine
Lua
3
star
13

modsec-analysis

ModSecurity event log analysis in bash.
Shell
2
star
14

mycroft_skills

Skill modules for the Mycroft AI
Python
1
star
15

dockerfiles

Sources for my Docker images
Dockerfile
1
star
16

puppetsec

Puppet scripts to lock down and secure Linux systems.
Puppet
1
star
17

mqtail

MQTT-based remote log viewer
JavaScript
1
star
18

traefik-example

Example of using Traefik to route to Docker containers
1
star
19

avsync

A tool for helping find audio/video offsets for synchronization.
Python
1
star
20

netback

Easily configurable backup script using rsync as a backend.
1
star