Pseudorandom thoughts generator.

I'm Niccolò Maggioni.
Student, geek and developer.

Upgrading Rancher v1.x & Docker

Initial notes

  1. If you are in doubt or instruction are unclear/outdated, always refer to the latest documentation.
  2. Throughout this guide {rancher_version} will represent a Rancher version including and up to the minor semver field (e.g.: v1.6).

Upgrading Rancher

Note: The following instructions are valid for the simplest non-HA permanent deploy of Rancher (referred to in the docs as SINGLE CONTAINER (NON-HA) - BIND MOUNTED MYSQL VOLUME).

  1. Check the latest documentation to see if anything obvious has changed or for the presence of warnings of any kind: http://rancher.com/docs/rancher/{rancher_version}/en/upgrading/.

  2. Stop the Rancher server container (adjust the container name to fit yours).

docker stop rancher-server
  1. Ensure that the folder containing Rancher’s MySQL database has the correct permissions for the container engine to access it (UID and GID are standard for every Rancher installation, they don’t rely on the host’s users/groups).
chown -R 102:105 /path/to/your/rancher/mysql-data
  1. Update your local Rancher server image (use latest instead of stable if you want to obtain the absolute latest version instead of the one recommended for production).
docker pull rancher/server:stable
  1. Restart the main Rancher container with the needed options (choose one from below) - make sure to append /mysql to Rancher’s MySQL folder path on host as the examples here do!

    • Simple setup with no extra capabilities enabled:

      docker run -d -v /path/to/your/rancher/mysql-data/mysql:/var/lib/mysql --restart=unless-stopped -p 8080:8080 --name rancher-server-1 rancher/server:stable
    • Setup with Prometheus monitoring enabled:

      docker run -d -v /path/to/your/rancher/mysql-data/mysql:/var/lib/mysql --restart=unless-stopped -e CATTLE_PROMETHEUS_EXPORTER=true -p 8080:8080 -p 9108:9108 --name rancher-server-1 rancher/server:stable
  2. Verify that the new container has started correctly; I usually let it run for a few minutes to check that it doesn’t crash.

docker ps | sed '1b;/rancher-server-1/!d'
docker logs -f rancher-server-1
  1. If everything went smoothly, remove the old container…
docker rm rancher-server
  1. …And rename the new one.
docker rename rancher-server-1 rancher-server

The last step is upgrading Rancher’s internal services too; login to your dashboard and, for every Cattle environment that you have, in the Stacks > Infrastructures section upgrade the stacks in the following order:

Remember to wait for a service to have completely finished (and user-confirmed via UI) its update before moving on to the next one.

Rancher’s Agents are binded to Rancher’s own version and are automatically managed by itself on the hosts, there’s no need to worry about them.

Upgrading Docker

Note: These instructions contian Debian-specific commands, but the general concepts apply on every distro. It is also given that you have the Docker repo already set up in your system.

  1. Check on the official docs which versions of Docker your current Rancher version supports: http://rancher.com/docs/rancher/{rancher_version}/en/hosts/#supported-docker-versions

  2. Update your local repo caches as usual.

sudo apt-get update
  1. Show which Docker versions are available.
apt-cache madison docker-ce
apt-cache policy docker-ce
  1. If needed and supported by Rancher, upgrade your Docker version (replace {DOCKER_VERSION} with your chosen one).
sudo apt-mark unhold docker-ce
sudo apt-get install docker-ce={DOCKER_VERSION}
  1. You can either restart Docker’s SystemD service or go with a full host reboot.
sudo systemctl restart docker.service
  1. After the restart (of either the service or the host), check Docker’s status.
systemctl status docker.service
journalctl -fu docker
  1. If any problems arise, try to wait 15-30mins for them to resolve by themselves - some combinations of Rancher/Docker upgrades can lead to slight incompatibility between components, causing timeouts and reconfigurations at the first start. If problems persist for longer or after a reboot, you can either roll back to the previous Docker version or dig deeper into SystemD’s journal to find the root of troubles.

  2. OPTIONAL: If nothing went wrong, prevent the accidental upgrade of Docker’s package in the future:

sudo apt-mark hold docker-ce

Found this article useful? Crypto makes for an excellent tip!


Share this