Docker Autocompose

Currently reading
Docker Autocompose

A user of the german Synology forum posted a bash snippet, which some of you mind find useful:
It will automaticly create a {container_name}-compose.yml per docker container, preconfigured with all settings the container had:
while read -r container_name; do
  docker run --rm -v /var/run/docker.sock:/var/run/docker.sock red5d/docker-autocompose ${container_name} > ${container_name}-compose.yml
done <<< "$(docker ps --format '{{.Names}}')"

Of course the red5d/docker-autocompose can be used for a standalone container as well:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock red5d/docker-autocompose $(docker ps -q --filter name=plex) > docker-compose.yml

Feel free to replace $(docker ps -q --filter name=plex) with a container name or id of your own choice.

What a nugget :)


DS216+II, DS118, DS718+
  1. RT2600ac
  2. MR2200ac
Operating system
  1. Windows
Mobile operating system
  1. Android
I have no experience with Docker Compose yet, but this sounds like a very easy method to have to fire up running containers again just like before, right?

In my situation with the combination of NordVPN and privoxy containers they do not start properly after a NAS reboot. That is because the NordVPN proxy container needs to be started up properly before the privoxy containers does. I guess with a Docker Compose files scheduled in task manager it should be eazier to tailor-made the automation of it?

Last edited:
Looks good to me :)

docker-compose will add a "project name" as a prefix to all it's objects (containers without "containername:), volumes, networks), which defaults to the directory name. Onthe top of my head, I am unsure if the directory name relates to the directory you execute the docker-compose command in, or the directory the docker-compose.yml is located in.

Just add docker-compose --file /path/to/you/compose.yml up -d for each compose yml you want to fire up.

I have just checked, it will add the old container name to the compose configuration, it will remain unchainged regardless of the project name.

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Welcome to! is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Similar threads

Similar threads

Trending threads