[Solved] Move rancher-server to another host

Since few weeks , i try to move my rancher UI - Single Container (non-HA) (1.16.10) to an other host.
all methods i can try failed :

  • copy database , the container on new host close with no error …
  • copy /var/lib/mysql on new host and mount at volume : container start and shutdown with no error … just exit 0
  • try with external database : cant connect to external database
    "Cannot create JDBC driver of class ‘’ for connect URL ‘null’"
    after start manually mysql service and load dump , i restart the containter and my result is :

[..] org.mariadb.jdbc.internal.util.dao.QueryException: Table 'region' already exists[..]
why? it’s must be like a just a reboot on the same version of rancher …

really need an export/import environment functionality…

Move server to another host with SSL Letsencrypt

The initial case use the rancher / server docker image containing its own database service.

Extraction or loading issues dropped the entire service and prevented full loading of the extracted data file from the source server.

Solution found:

On source server, you have to copy make a copy of the rqd mysql bdd directory

on the source host

   $ docker cp <container-name-rancher-server>:/var/lib/mysql ./
   $ tar czvf mysql.tgz mysql

To perform on the target host

$ scp rancher @ <host_source>: ~ / rancher-server / mysql.tgz ./
$ tar xzvf mysql.tgz
$ chmod 102:105 -R mysql

use a docker-compose.yml like :

version: "3"
services:
        nginx-proxy:
            image: jwilder/nginx-proxy:latest
            ports:
               - "80:80"
               - "443:443"
            volumes:
               - '/home/rancher/nginx-proxy/ssl:/etc/nginx/certs:ro'
               - '/etc/nginx/vhost.d'
               - '/usr/share/nginx/html'
               - '/var/run/docker.sock:/tmp/docker.sock:ro'
        letsencrypt-nginx-proxy-companion:
            image: ppottie/letsencrypt-npc:latest # specific  image for certif generation (like letsencrypt-nginx-proxy-companion but on old version)
            volumes:
               - '/home/rancher/nginx-proxy/ssl:/etc/nginx/certs:rw'
               - '/var/run/docker.sock:/var/run/docker.sock:ro'
               - '/etc/nginx/vhost.d'
               - '/usr/share/nginx/html'
        rancher-server:
            image: rancher/server:latest
            volumes:
                    - "/home/rancher/rancher-server/mysql:/var/lib/mysql"
            environment:
               VIRTUAL_PORT: 8080
               VIRTUAL_HOST: <URL_HOST>
               LETSENCRYPT_HOST: <URL_HOST>
               LETSENCRYPT_EMAIL: <EMAIL>

In case someone finds this, I also wrote a gist on this process before: https://gist.github.com/superseb/f610bad1608d6ae5398e5dfc8d735cc7