“Misplaced” your compose.yaml? Or want to capture the config of a container (or stack of containers) deployed with docker run or Portainer?

docker-autocompose can help with that.

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
  ghcr.io/red5d/docker-autocompose \
  <container-name-or-id> <...> \
  > compose.yaml

To capture the entire stack of containers with wordpress in the name (eg wordpress-db-1 and wordpress-wordpress-1):

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
  ghcr.io/red5d/docker-autocompose \
  $(docker ps --filter "name=wordpress" -q) \
  > wordpress-compose.yaml