Skip to content

Instantly share code, notes, and snippets.

@Klizzy
Last active March 28, 2023 21:24
Show Gist options
  • Save Klizzy/444f52a31c9fb9eeb163f4dd0f23e6d5 to your computer and use it in GitHub Desktop.
Save Klizzy/444f52a31c9fb9eeb163f4dd0f23e6d5 to your computer and use it in GitHub Desktop.
translate docker commands into the docker-compose.yml format

Translate docker commands into the docker-compose.yml format

Create bash / zsh alias and name it as you wish

  1. Install composerize e.g with yarn yarn global add composerize
  2. add alias trans-docker='f(){ composerize "$@" | cat -p --language yaml; unset -f f; }; f' into your ~/.zshrc or ~/.bashrc
  3. reload your shell
  4. convert your docker run command like this:
trans-docker docker run --name='mailcatcher' -d \
  --publish=1080:1080 \
  --publish=1025:1025 \
dockage/mailcatcher:0.7.1

Output

version: '3.3'
services:
    mailcatcher:
        container_name: mailcatcher
        ports:
            - '1080:1080'
            - '1025:1025'
        image: 'dockage/mailcatcher:0.7.1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment