Upgrade Mikrotik containers

The need to update

I’m quite happy with my Pi-hole setup on my Mikrotik router. Since I changed the USB drive to a faster one I don’t have any issues with it. Turns out write speeds are actually an important factor for these kind of use cases, who would have thought.

However, if you remember my previous post in this topic, you’ll notice (or not) that I used a very specific tag pulling the Pi-hole image:

/container/add remote-image=pihole/pihole:2022.11.1 interface=veth1 root-dir=disk1/pihole mounts=dnsmasq_pihole,etc_pihole envlist=pihole_envs

As I explained it there, I don’t like to use the latest tag for mission critical stuff. Also I’m not that brave to install watchtower on my router to handle the automatic upgrade. So I need a way to manually upgrade my Pi-hole container from time to time.

The solution

It turns out the process is really simple. We are storing all of our configuration independent from the docker image (as it should be), so the only thing needed to update the container is a few commands.

Preparation

First, change the DNS server to something different from the Pi-hole one, so we’ll have name resolution during the upgrade:

/ip dns set servers=1.1.1.1

Then stop the container and remove the image (I assume that the container number is 0 for you too, if in doubt run a /container/print command):

1
2
/container/stop 0
/container/remove 0

Upgrade

Now we have to pick a version we are happy with and pull the image:

/container/add remote-image=pihole/pihole:2023.01.10 interface=veth1 root-dir=disk1/pihole mounts=dnsmasq_pihole,etc_pihole envlist=pihole_envs

After the image is extracted (you can check the status with the print command or just take a look at the container settings in WebFig or WinBox) we will need to manually start it:

/container start 0

Revert the DNS setting

Don’t forget to replace the DNS server to the Pi-hole IP if everything is running fine:

/ip dns set servers=172.17.0.2

Conclusion

That’s it! It’s a simple and foolproof way to upgrade your containers. In the future I’ll perhaps take a chance with the latest tag after all but for now this is working fine for me and it takes around 10 minutes to do.