首页 / 工具实用 & 趣味编程 / Docker Compose Autogenerator
通用工具实用 & 趣味编程直接可用

Docker Compose Autogenerator

version: "3.9" services: {{ foreach container in containers }} name: {{ container.Id }} image: "{{ container.Image }}" ports: "{{ port.Mappings[0].Hos…

完整提示词共 1061 字,复制不受页面折叠影响
version: "3.9"
services:
  {{ foreach container in containers }}
    - name: {{ container.Id }}
      image: "{{ container.Image }}"
      ports:
        - "{{ port.Mappings[0].HostPort }}:{{ port.Mappings[0].Proto }/tcp "
      environment:
        - "{{ env.Name }}={{ env.Value }}"
      volumes:
        - "{{ mount.Source }}:{{ mount.Destination }}"
      depends_on:
        - "{{ network.Name }}"
  {{ end }}
volumes:
  {{ foreach volume in mounts }}
    - name: {{ volume.Name }}
  {{ end }}
networks:
  {{ foreach network in networks }}
    - id: {{ network.Name }}
  {{ end }}
containers:
{{ foreach container in inspect_output }}
- Id: {{ container.Id }}
image: {{ container.Image }}
state:
  running: true
config:
  env:
    - name: NGINX_VERSION
      value: "1.21.4"
exposed_ports:
  port_80tcp:
    host_port: 8080
network_settings:
ports:
  port_80tcp:
    host_port: 8080
volumes:
- name: nginx_data
  source: /var/lib/docker/volumes/nginx_data/_data
  destination: /usr/share/nginx/html
depends_on:
- network_name: {{ network.Name }}
{{ end }}
变量模板工具

填写变量,一键生成完整提示词

所有字段会实时替换到原始提示词中;未填写的变量会保留,方便继续编辑。

生成结果 · 1061 字
version: "3.9"
services:
  {{ foreach container in containers }}
    - name: {{ container.Id }}
      image: "{{ container.Image }}"
      ports:
        - "{{ port.Mappings[0].HostPort }}:{{ port.Mappings[0].Proto }/tcp "
      environment:
        - "{{ env.Name }}={{ env.Value }}"
      volumes:
        - "{{ mount.Source }}:{{ mount.Destination }}"
      depends_on:
        - "{{ network.Name }}"
  {{ end }}
volumes:
  {{ foreach volume in mounts }}
    - name: {{ volume.Name }}
  {{ end }}
networks:
  {{ foreach network in networks }}
    - id: {{ network.Name }}
  {{ end }}
containers:
{{ foreach container in inspect_output }}
- Id: {{ container.Id }}
image: {{ container.Image }}
state:
  running: true
config:
  env:
    - name: NGINX_VERSION
      value: "1.21.4"
exposed_ports:
  port_80tcp:
    host_port: 8080
network_settings:
ports:
  port_80tcp:
    host_port: 8080
volumes:
- name: nginx_data
  source: /var/lib/docker/volumes/nginx_data/_data
  destination: /usr/share/nginx/html
depends_on:
- network_name: {{ network.Name }}
{{ end }}

使用建议

  1. 先用默认结构运行一次,确认模型理解角色与任务。
  2. 再填写具体主题、对象、语气和输出格式,结果会更稳定。
  3. 如果更换 AI 平台,可从页面顶部的平台专区继续筛选适配版本。