Red5d / docker-autocompose

Generate a docker-compose yaml definition from a running container
1.76k stars 197 forks source link

Add wildcard container selection and some code cleanup #47

Open d-EScape opened 1 year ago

d-EScape commented 1 year ago

For lack of a better name I called the option --wildcard (-w). It will select all containers that have the specified text in their names. Use case: easily create stack files to import in portainer. Example: I have renamed my domotica related containers to dom.domoticz, dom.mqtt, dom.zwave etc. I can create 1 stack file by doing a 'autocompose.py -w dom.'

output has been checked with docker-compose config

Red5d commented 1 year ago

@d-EScape The wildcard addition is appreciated, though could you please review the conflicts here? I looked through to try and fix them myself, but not sure exactly how some of your "code cleanup" items will work with the most recent updates.

d-EScape commented 11 months ago

Thanks @demon! The regex approach in #57 looks much more elegant. It does however also export all networks when filtering on --all (e.g. ./autocompose.py -f "someprefix.*" -a). That is because of lines 120-122.

if args.all:
        host_networks = generate_network_info()
        networks = host_networks

Is there any reason for exporting unused networks in that case? If so, can you change this to

 if args.all and not args.filter:
        host_networks = generate_network_info()
        networks = host_networks