Docker Compose MySQL Keeps Restarting

Run into a strange bug where the MySQL container would keep restarting. The error I would see from the logs would be

[ERROR] --initialize specified but the data directory has files in it. Aborting.

You can view container logs by typing

docker logs -f <db_container_name>

I tried to rebuild the container by running

docker-compose build and docker-compose up -d but to no avail. Finally stumbled on a solution via a GitHub issue here. The solution was to run

docker system prune --volumes

which cleared out the said directory then after building the container worked.

Read this article

High Availability using Round Robin DNS

A couple of months ago I wrote about using Nginx as a load balancer to ensure uptime. However this still leaves a single point of failure e.g. if the load balancer goes down this means the client cannot reach your application servers. One solution to this is to have a secondary load balancer. How would such a setup work?

Round Robin DNS

To make use of this we would need to have multiple A records for a particular domain. For example say our endpoint is we would need to have an A record pointing to load balancer 1's IP address and another A record pointing to load balancer 2's IP address. When a user types the domain name into the browser, DNS will return a list of IP addresses that point to the said resource, most Http clients will try the first IP in the list, if this is unavailable it will try the second one and so on. So if the first IP is unresponsive they will be directed to the second IP, all this of course is transparent to the user.

Sample Round Robin DNS Setup


Sometimes some http clients will not attempt to try the second IPs unless the user does a page refresh, other times because of a DNS cache the browser may not have the secondary IP available. DNS propagation is also something to consider. This method will not work for application level errors on your load balancer, thus it is important to have monitoring for the application health of your load balancers. Something else to consider is that you now have multiple servers to manage. For example now when generating SSL certificates you'll need to make them available to both load balancers.

Are there other techniques you are using to ensure HA for your applications?

Read this article

Hiking Mt. Satima

Dragon's Teeth

After months of lock-down in the city we got a chance to explore the outdoors. We settled on hiking Mt. Satima located in the Aberdares. Mt. Satima is the third highest point in the country standing tall at 4001 m. During this unique time we had to try and do what would be a 7-8 hour hike and be back in Nairobi before the 9 pm curfew. This meant we had to start early (4 am madness eh?).

There are two ways you can hike Mt. Satima one through Wandare gate or Shamata gate. Our contact person recommended the Shamata route as it was the more scenic option albeit a bit longer. We approached Shamata gate from Nyeri and entered the park through Rhino gate. To take this route travel up to Nyeri then take the Nyeri - Nyahururu road until a few kilometres before Wiyumiririe town. The distance from Rhino gate to the starting point for the hike (Twin Rocks) is about 12 km. We picked up our guide/ranger at the KWS outpost at Rhino gate.

The costs for such a trip is (2020 rates):

  • Park fee - Ksh. 250 (current discounted rate) per person
  • Guide fee - Ksh. 3015 per group
  • Vehicle fee - Ksh. 300 per vehicle (5 seater)

Suggested plan

  • Start trip at 4.00 am
  • Arrive at Rhino gate by 8.00 am
  • Start hike by 8.30 am from Twin Rocks
  • Summit by 2 pm or stop the hike at Dragon's Teeth if you hope to make it back before 9 pm
  • Finish descent by 4 pm to start trip back to Nairobi
  • Leave park by 4.30 pm for a 4 hour trip back to Nairobi
  • Alternatively plan to spend the night around Nyeri so there will be no mad rush to beat curfew

Stuff you need

  • A change of clothes (shoes, t-shirt, trousers, socks)
  • Warm clothes for the hike as it will get cold (several layers, plus covering for the head/face, gloves)
  • Hiking boots
  • Comfortable pair of trousers (avoid jeans)
  • Athletic t-shirts (the running ones)
  • Water (2 liters)
  • Snacks (sugary stuff to keep you going, trail mix)
  • A rain jacket
  • A camera (please carry an extra card don't be like me)
  • Identification documents

Pictures from the trip

Midway our journey I realized I carried a bad memory card meaning my camera was effectively useless (don't be like me) so I had to take the trip shots using my phone. In a way this was a good thing less weight plus no constant worry about missing the shot. All these shots were captured using my trusty Pixel 3a.

Mt Satima

Stuff to note

Nothing could have prepared us for how wet the ground was we literally at one point were wading through water. Our guide who had gum boots also got wet. I think the only way to prepare for this is to have an extra change of clothes including shoes and socks. It can also get really cold so dress warm without carrying too much weight. We couldn't get to the summit so because of time constraints so keep an eye out for your timing, if you realize you are running late you can terminate the hike at Dragon's Teeth. Don't carry unnecessary weight. When planning such we tend to overestimate what we will really need, keep it simple you'll have more fun that way. Don't forget to soak in the views.

Read this article