Keith A Alston
4 min readJun 7, 2023

DOCKER SWARM….

When you combine Docker container services with the Swarm Prince of Bel-Air, you should get DOCKER SWARM right? NO, not all entirety but below I will attempt to share how I created and deployed a 3 node Docker Swarm cluster with a few additional services…

First we create 3 separate instances with PRIVATE ip address, only use a public IPv4 address when you happen to stop and restart your instance.

USE UBUNTU 22.04 WITH T2.MICRO INSTANCE TYPE
MAKE SURE YOU NAME YOUR SECURITY GROUP NAME EXAMPLE (NODE1 WEEK17) FOR EACH INSTANCE
THIS ALLOWS DOCKER TO BE INSTALLED BUT FOR ME IT DID NOT WORK SO I INSTALLED IT IN TERMINAL LATER ON…

YOU WOULD REPEAT THE SAME FOR INSTANCE 2-NODE 2 AND INSTANCE 3- NODE 3

Next would be to connect all nodes through Visual Studio Code

click green box in lower corner to start configuration

green box, connect to host, configure ssh host..

“DAD” IS MY NAME OF COMPUTER

Once configured, now we must change our hostname for our EC2 to node1

Use the command sudo hostnamectl set-hostname node1,

REBOOT/REFRESH instance….

SAME PROCESS FOR NODE 2 AND NODE 3…..

Once in, now I have to create the WordPress service

THIS IS WHERE I INSTALLED DOCKER VS IN USER DATA BOX

The above meme sums up the amount of self inflicted pain I caused myself, hours of pain and basically not just locking into what the errors were saying…I will share a few error screenshots and explain thereafter…

why did i run this command with a nginx image?

I simply changed out nginx with WordPress

why am I running a compose file when it clearly says I’m in a swarm mode?
more errors

Again, as embarrassing as it looks, the solution was clearly right in front of my face MULTIPLE TIMES. It clearly stated that I was in swarm mode so the compose command would not work.

I would like to add that these errors and inability to find the solution took a toll. Why did I just LOOK at what the errors clearly said? I honestly got lost in the sauce per say of trying to compete the task quickly, that can and did cause wasted time which was a great learning experience moving forward.

A simple command… sudo docker stack deploy?

docker stack deploy error?
Respectfully the meme has a purpose….

PLEASE READ….the previous command line screenshot showed that I did not have the correct command. While I tried my best to figure out the right command, I reached out to a fellow teammate seeking assistance all the while Beyoncé song “say my name” was blasting in someone car next door and immediately and near simultaneously my teammate text me saying that I needed to NAME my docker compose yaml file. Strange but thankful for the help AND knowing that I was on the right path with the musical sign next to me. That may or may not pertain to the topic at hand but I do believe that if you work hard and sincerely desire to do the right thing, signs will come your way.

DOCKER STACK DEPLOY COMMAND.DOCKER STACK SERVICES

Docker stack deploy -c docker-compose.yaml week17Keith shows deployment of stack with no errors and services command shows 3 replicas for WordPress and 1 for MySQL.

…..After many many attempts, I and a handful of my teammates were unsuccessful in accessing from localhost:80

This would be something out of our control based on what most have been experiencing.

There you have it, another project learning experience troubleshooting errors and building tech confidence and comradery. I appreciate you taking the time to read another chapter in my journey.

Who’s next??….Kubernetes!

Keith A Alston
Keith A Alston

Written by Keith A Alston

USAF vet aspiring goals in Cloud/DevOps Engineering with years of experience in physical security as well as holistic health and wellness and physical fitness.

No responses yet