How to upgrade a docker swarm node from ubuntu 17.04 to 17.10

I recently needed to upgrade the nodes in a docker swarm cluster from ubuntu 17.04 to ubuntu 17.10 when 17.04 went unsupported. The following steps were used.

1. Update apt to use the old sources

Once 17.04 went unsupported I was no longer able to run apt update b/c the apt sources were no longer available. To fix this I updated the /etc/apt/sources.list to contain the following sources:

#EOL Sources
deb zesty main restricted universe multiverse
deb zesty-updates main restricted universe multiverse
deb zesty-security main restricted universe multiverse

2. Update apt

Now that the new sources are in place we can update apt with sudo apt update

3. Upgrade packages

Next we update to the latest version of packages that are available with sudo apt upgrade

4. Drain the swarm node

Before you upgrade the ubuntu distribution we have to make sure that any active tasks are moved off of the current node and onto a different active node so that we don't disrupt any services. You can verify the status of the node that you are working on by running docker node ls. You should see your node in the output with a STATUS of "Ready" and AVAILABILITY of "Active". You can also see which tasks are running on the given node by running docker stack ps <stack name> | grep <node name>. This will show the tasks that are active on the node that you are about to upgrade.

To drain the node you run docker node update --availability drain <node name>. If you now run docker node ls again you should see the AVAILABILITY is now set to "Drain"

Upgrade the ubuntu distribution

Now that the swarm node is drained we can update the ubuntu distribution by running sudo apt dist-upgrade and then sudo do-release-upgrade and following the prompts.

Add back any custom apt source repositories

If you have any custom apt source repositories we have to add those back. In my case, I needed the updated docker sources. I added those back by running:

sudo add-apt-repository \
   "deb [arch=amd64] \
   $(lsb_release -cs) \

Activate the swarm node

Once the update is complete we can reactivate the swarm node by running:

docker node update --availability active <node name>

You can confirm that the node is back active by running:

docker node ls

This should show that the AVAILABILITY of the node is now back to "Active"