Move rancher/server container with volumes to other host + change of DNS name (Host Registration URL/CATTLE_URL/API URL) for Rancher 1.6
This applies to Rancher 1.6 only
- Old URL: http://old.test.com:8080
- New URL: http://new.test.com:8080
- Container name running
rancher/serverimage:rancher_server - Old host:
oldhost - New host:
newhost
- Go to Admin -> Settings and change the Host Registration URL to http://new.test.com:8080
- Stop the docker container running the
rancher/serverimage onoldhostsudo docker stop rancher_server
- Backup the files of the MySQL database on
oldhostsudo docker run --rm --volumes-from rancher_server-v $(pwd):/backup busybox tar cvf /backup/mysql.tar /var/lib/mysql
- Transfer the resulting archive (
mysql.tar) over fromoldhosttonewhost - Restore the files of the MySQL database to a new data volume
- Create data volume:
sudo docker create -v /var/lib/mysql --name rancher-data busybox true - Extract archive into data volume:
sudo docker run --rm --volumes-from rancher-data -v $(pwd):/backup busybox tar xvf /backup/mysql.tar - Check contents of data volume:
sudo docker run --rm --volumes-from rancher-data busybox ls /var/lib/mysql
- Create data volume:
- Run
rancher/serverusing the data-volume onnewhostdocker run -d -p 8080:8080 --volumes-from=rancher-data --restart=unless-stopped rancher/server:v1.6.10- Check that no SQL errors appear
- We need to re-register any hosts running
rancher/agentbecause of the changed URL- In the UI, go to Infrastructure -> Hosts, Add Host, Custom
- Copy the command and run it on every host running the
rancher/agentcontainer
- Because of rancher/rancher#9307 we need to delete the containers belonging to the following infrastructure services:
- Be aware, delete containers only, not stacks or services as they will not return otherwise.
- metadata
- healthcheck
- loadbalancers
- scheduler should recover itself, but you can delete this aswell
- Wait for infrastructure services to become active/green
Can this guide be applied to Rancher 2+?