This will use a Docker container called docker-autocompose to export a current Docker container and its settings to YAML text so you can past it into a stack inside Portainer.
Use the new image to generate a docker-compose file from a running container or a list of space-separated container names or ids. This one is the easiest to start with:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose <container-name-or-id> <additional-names-or-ids>...
To print out all containers in a docker-compose format:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose $(docker ps -aq)
And this will output a docker-compose compatible yaml structure.
Here are some examples:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose mariadb
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose nextcloud
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose handbrake
After running this or these commands, you can take the output and create a stack inside Portainer for example to create a new container. You can also change what you want to have in the stack. Maybe you don’t want all the settings, just the basic. Then remove everything you don’t need and past it into the stack.
If you want to watch a video on how to do it, you want watch this on YouTube from the amazing DB Tech.