https://github.com/darmiel/d2dc
Small utility to convert `docker run [...]` to `docker-compose`
https://github.com/darmiel/d2dc
cli-app docker docker-compose go golang hacktoberfest
Last synced: about 1 year ago
JSON representation
Small utility to convert `docker run [...]` to `docker-compose`
- Host: GitHub
- URL: https://github.com/darmiel/d2dc
- Owner: darmiel
- Created: 2021-03-09T13:08:59.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-01T10:10:24.000Z (over 3 years ago)
- Last Synced: 2025-03-26T22:31:58.557Z (about 1 year ago)
- Topics: cli-app, docker, docker-compose, go, golang, hacktoberfest
- Language: Go
- Homepage:
- Size: 281 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# d2dc
**D**ocker **2** **D**ocker-**C**ompose


[](https://github.com/darmiel/d2dc/actions/workflows/go-build.yml)
---
d2dc converts a `docker run`-command into a docker-compose service (see [example](#example)).

---
* [Example](#example)
* [Build](#build)
+ [Prerequisites](#prerequisites)
+ [Build](#build-1)
* [Why?](#why-)
---
## Example
**INPUT:**
```bash
$ docker run -it --rm --name ftp -p 21:21 -e "HELLO=WORLD" -v "${PWD}/data":/data myimage:latest
```
**OUTPUT:**
```bash
services:
ftp:
image: myimage:latest
stdin_open: true
tty: true
environment:
HELLO: WORLD
volumes:
- ./data:/data
ports:
- "21:21"
```
## Installation
If you have Go installed, you can use the following command to get d2dc:
```bash
go install github.com/darmiel/d2dc/cmd/d2dc@latest
```
## Build
### Prerequisites
* Go 1.15+
* Git (or just download the tarball [here](https://github.com/darmiel/d2dc/archive/refs/heads/main.tar.gz))
### Build
Build builds the project and outputs the executable file in the root folder
```bash
$ git clone https://github.com/darmiel/d2dc
$ cd d2dc
$ go build ./cmd/d2dc
# (optional): Install to path:
$ go install ./cmd/d2dc
```
## Why?
I wanted to learn a bit of the commands for `docker run` and so I thought this would be a good project to learn those commands.