Last active
May 29, 2020 12:57
-
-
Save gerritdrost/19b2fd972127c4292241a0bf1fce4424 to your computer and use it in GitHub Desktop.
Script to generate docker-compose.yml with many services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import yaml | |
service = {'image': 'alpine:latest', 'command': 'sleep 30'} | |
docker_compose_yaml = { | |
'version': '3.4', | |
'services': {} | |
} | |
for i in range(int(sys.argv[1])): | |
docker_compose_yaml['services']["service_%03d" % i] = service | |
yaml.Dumper.ignore_aliases = lambda *args: True | |
print(yaml.dump(docker_compose_yaml, default_flow_style=False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment