You might be wondering why would you need to run a docker-compose container in the first place? Well, if you look at Synology's Docker UI, you will find out soon that it does not cover all potential options and features that you might need with certain solutions out there that you want to run inside Docker.
That will turn you towards a docker-compose file that will have all the instructions needed to run the container, and in order to run it, you start by going into the command line and run a simple single line.
So what's the advantage of running a "Stack" using Portainer? Well, you have a nice UI that will give you all the tools needed including a web editor that will check if the YML file is formated and structured correctly. Meaning you will be able to have a color-coded docker-compose file ready to be executed and changed on the fly if you have the need to do it.
There are several ways you can start with docker-compose in Portainer. As you can see from the image above, there are four methods of doing this.
Web editor , uploading a file , using a GIT repository , or using a custom template .
For my personal use case, I use web editor or upload methods just because most of the time I just write my own compose files, or if I already have them saved, simply upload them or again just copy the content of the file into the web editor.
Another reason I favor web editor is that I can just quickly edit (and correct it if needed) the composed file content and redeploy the container.
Bad indentation in line 16. Another great asset of Portainer web editor
Portainer Stacks
Example of Stack options
Now just to be clear you can still use and manipulate your container created via the Stack the same way as you would any other container. As you can see on the image above, there are still tools that allow you to start, stop, kill or restart your container.
On top of these tools, you will have the section on Stack tools as well. There is a way to stop, delete and create a template from that stack.
In case you were wondering, stoping the Stack will stop all the containers in the stack and there will be no exceptions around this, so choose what containers you want to be part of a single Stack.
One thing that you can also see is that while the container and stack are running you also have access to the Editor part of the Stack.
Edit the Stack/Container and redeploy in a matter of seconds
From the above example you can see that while the Container is in the running state, you can edit the docker-compose and use the Update the stack button to remove the old container and redeploy a new one.
One example that this might be useful is that you want to change the port number on the fly, or use a different image tag to deploy the same container but with a new repo tag, or just change the name of the container. The point is that you have it all right there in a single window with no need to use a different code editor, save your changes, and then use the up/down docker-compose CLI command.
Manage "Stacks" created outside Portainer
Now there are some cases at the moment that you might not be able to use the full potential of docker-compose CLI commands inside Portainer. One example is using the env_file
command.
Just to show you how a "Stack" (or how it is called a "project") created via command line looks like on the Portainer end.
"Stack" created using docker-compose command line
Clear notice that control over the Stack will be limited
If we compare the images you will notice that the stack tools are missing. So there are no options to stop, delete or make a template out of this Stack if it was not initiated from the Portainer in the first place.
Still, you do have an overview and you can control the containers that are the result of this stack.
Not really a topic for this particular article but will just mention one thing about agents that will in the end make sense when dealing with Stacks.
Portainer agents - aggregate your Docker hosts in a single UI
One more way that a web editor might be handy is the quick deployment of the same container on multiple Docker hosts. Templates or again, web editor, can come in handy to switch from one host to the other using the same Portainer UI.
Let's say you have a Portainer host running on one of your Docker hosts, but you also have a number of other Docker hosts as well. Instead of having multiple Portainers on all of those hosts, and the need to log into each of them, why not pull them together under a single Portainer instance with Agents ?
Info on how to connect multiple Docker hosts using the agents can be found in Luka's other Portainer article here , under the Add Docker host to your Portainer using an agent heading.
The reason I am saying this is that in this configuration there are other cool benefits of running stacks and using Portainer at the same time.
Migration and duplication of stacks
If you have a Docker Swarm cluster up and running and controlled by the Portainer or simply have multiple hosts connected with agents, you can migrate your Stack from one host to the other.
Stack about to be migrated to a new host
Once you have decided on the Stack you want to migrate, give it a new destination name and select the host from the list of endpoints.
One final warning and confirmation
To make this happen and work keep a few things in mind:
Volume bind and content will NOT be migrated, on top of that make sure that if you do use any volume binds or mounts they need to be prepared beforehand on the destination side (same as always), and finally, if there will be any clash of the port mappings (port in use ), your migration will fail.
So basically, just like when you are making a new fresh Container/Stack on your host, you will need to make sure that all those prerequisites are met in the migration process as well.
Conclusion
If you are serious about Containers on any platform, you should consider using Portainer. It will allow you all the features that Docker offers, as well as allow you to use it with Kubernetes, Docker Swarm, and Azure ACI.
There are still people that like to use CLI of course and there is nothing wrong with that, but Portainer will be there for anyone that wants to have a powerful UI to do all those tasks. Also, with its support for users and teams, Portainer will be a one-stop-shop for all your collaborative needs as well.
Let me know down in the comments if you use Portainer, and for what, and if so, has it helped you out, or is it missing some features that you need or would like to be able to use.
Try Portainer with 3 Nodes Free
If you're ready to get started with Portainer Business, 3 nodes free is a great place to begin. If you'd prefer to get in touch with us , we'd love to hear from you!
COMMENTS