Updated on June 7th, 2016 Having a bit more experience with Docker and running Unifi as a container I thought it was time to update this page a bit.
Containers bring a slightly different approach to operations. So now that we covered Migrating a UniFi Controller to a Docker container lets go over upgrading the controller container.
Manual Updates
This is pretty simple if we’re using a volume container to persist the volumes/data.
First step is to pull the new version of the docker image, if one exists.
docker pull jacobalberty/unifi:latest
If there’s no update then the output will look like this and we can stop here.
docker pull jacobalberty/unifi:latest
latest: Pulling from jacobalberty/unifi
Digest: sha256:00c74846ba55f45d122b36db70acb24343bc912b3b828056ec99224459e91db5
Status: Image is up to date for jacobalberty/unifi:latest
If there’s an update then you’ll see something that looks like this.
docker pull jacobalberty/unifi:latest
latest: Pulling from jacobalberty/unifi
523ef1d23f22: Pull complete
140f9bdfeb97: Pull complete
e204e64c8c06: Pull complete
8ff750d6880c: Pull complete
8253b8db2ea3: Pull complete
e961219c0131: Pull complete
d5b201fd4961: Pull complete
6eaecbda1889: Pull complete
2a757692ad44: Pull complete
a9f46c5c4e70: Pull complete
864133544f19: Pull complete
0bce3b6fbaf0: Pull complete
7819d2cdfbeb: Pull complete
6991934144a8: Pull complete
Digest: sha256:00c74846ba55f45d122b36db70acb24343bc912b3b828056ec99224459e91db5
Status: Downloaded newer image for jacobalberty/unifi:latest
Replacing the container
docker stop unifi
docker rm unifi
docker run --name=unifi --net=host --volumes-from unifi-data -d jacobalberty/unifi:latest
Restart the container as a service If the container is running as a service we’ll need to stop the new unifi container and start the service.
Upstart
docker stop unifi
sudo service unifi start
Systemd
docker stop unifi
sudo systemctl start unifi
You should now be running the latest docker container.
Scripted Upgrades
This script only supports systemd but can be modified to support other ways of running the container. But with this to upgrade the container simply run
sudo upgrade_unifi
/usr/local/bin/upgrade_unifi
#!/usr/bin/env bash
docker pull jacobalberty/unifi:latest
if docker ps | grep -q "jacobalberty/unifi"; then
echo "Already running latest image"
else
echo "New image pulled"
echo "Upgrading container"
systemctl stop unifi
docker rm unifi
docker run --name=unifi --net=host --volumes-from unifi-data -d jacobalberty/unifi:latest
docker stop unifi
systemctl start unifi
fi
chmod +x /usr/local/sbin/upgrade_unifi