如何从当前运行状态生成docker撰写文件

时间:2019-11-24 13:27:08

标签: docker docker-compose dockerfile

我想根据我的docker执行状态生成一个docker-compose.yml文件。

例如:

docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                                                                                                   NAMES
9fc796bd5523        grafana/grafana:4.1.1      "/run.sh /run.sh"        5 days ago          Up 4 days           0.0.0.0:3033->3000/tcp                                                                                  blah_grafana_1
c13b1737674d        prom/prometheus:v1.5.2     "/bin/prometheus -co…"   5 days ago          Up 4 days           0.0.0.0:9291->9090/tcp                                                                                  blah_prometheus_1
0257d43cb810        redis                      "docker-entrypoint.s…"   5 days ago          Up 4 days           6380/tcp, 0.0.0.0:6380->6379/tcp                                                                        blah_redis_1
2052dde0faa7        wurstmeister/zookeeper     "/bin/sh -c '/usr/sb…"   5 days ago          Up 4 days           22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:21811->2181/tcp                                                     blah_zookeeper1_1
....
....
....
....
....

会像这样生成docker-compose.yml骨架:

version: '2'
services:
  redis:
    ...
    ports: ...
    expose: ....
    links: kafka , redis , grafana ... etc. etc.
    ...
  kafka:
    ...
    ports: ...
    expose: ....
    links: kafka , redis , grafana ... etc. etc.
    ...
  grafana:
    ...
    ports: ...
    expose: ....
    links: kafka , redis , grafana ... etc. etc.
    ...
  zookeeper:
    ...
    ports: ...
    expose: ....
    links: kafka , redis , grafana ... etc. etc.
    ...

....
...

0 个答案:

没有答案