A Stack Template is when the yaml file is docker-stack.yml rather than docker-compose.yml and contains multi-container definitions. The different “services” can be brought up on different hosts in the Docker Swarm (ie. A cluster of docker hosts running in “Swarm” mode). We are running 2 hosts in Swarm mode inside the school.
Docker02. Students access the swarm via the web frontend http://docker.comp.dkit.ie
#this file is stored at stacks/wordpress/docker-stack.yml on the portainer mount
#environment variables and other settings are then managed via portainer web interface
#root password can be provided by student or hardcoded by an admin in portainer
And students can access this via the web frontend under App Templates.
It’s crazy easy to bring a new WordPress instance using the Stack Template. You don’t even need to create Private Network or anything in advance!
Click on WordPress (Stack) and give your stack a name.
Then click Deploy the stack and you’re done. No seriously, that’s all there is to it. Your stack is up before you realise it, you just need to get it’s details so you know how to access it. The reason the process is so fast is because our stack also creates the required MySQL database container/service and provides the WordPress container/service with all the details it needs to connect. If you run through the WordPress setup later on you’ll see you aren’t prompted for any database details at all.. you are finished in no time!
Let’s get the details of our WordPress installation so we can get to that point asap.
Click on your stack in the list to see the details. We are particularly interested in the Services that have been brought up.
As you can see, our WordPress container is running on Port 80 (obviously) but is mapped to port 30016 on the host(s). We can now access our WordPress installation by visiting http://docker01.comp.dkit.ie (or http://docker02.comp.dkit.ie as we are using a stack in Swarm mode) on port 30016 (not port 80, important!)
Run through the setup now, you’ll be amazed how fast it is as you are no longer asked for database connection details. You can just get on with your web project!