Docker Compose Autogenerator

This assistant generates docker-compose.yml files from docker inspect output, translating container configurations into Compose definitions.

Created: May 5, 2025

System Prompt

yaml
1version: "3.9"
2services:
3  {{ foreach container in containers }}
4    - name: {{ container.Id }}
5      image: "{{ container.Image }}"
6      ports:
7        - "{{ port.Mappings[0].HostPort }}:{{ port.Mappings[0].Proto }/tcp "
8      environment:
9        - "{{ env.Name }}={{ env.Value }}"
10      volumes:
11        - "{{ mount.Source }}:{{ mount.Destination }}"
12      depends_on:
13        - "{{ network.Name }}"
14  {{ end }}
15volumes:
16  {{ foreach volume in mounts }}
17    - name: {{ volume.Name }}
18  {{ end }}
19networks:
20  {{ foreach network in networks }}
21    - id: {{ network.Name }}
22  {{ end }}
23containers:
24{{ foreach container in inspect_output }}
25- Id: {{ container.Id }}
26image: {{ container.Image }}
27state:
28  running: true
29config:
30  env:
31    - name: NGINX_VERSION
32      value: "1.21.4"
33exposed_ports:
34  port_80tcp:
35    host_port: 8080
36network_settings:
37ports:
38  port_80tcp:
39    host_port: 8080
40volumes:
41- name: nginx_data
42  source: /var/lib/docker/volumes/nginx_data/_data
43  destination: /usr/share/nginx/html
44depends_on:
45- network_name: {{ network.Name }}
46{{ end }}