Skip to content

Instantly share code, notes, and snippets.

@stigfromsouth
Last active January 25, 2022 06:50
Show Gist options
  • Save stigfromsouth/8172f0f26585a133d6c1c5bd5d9875da to your computer and use it in GitHub Desktop.
Save stigfromsouth/8172f0f26585a133d6c1c5bd5d9875da to your computer and use it in GitHub Desktop.
How to migrate rocketchat docker containers on another server

Migrate rocketchat docker containers on another server

List our containers on old server

$ docker container list
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                    NAMES
9406c8b05996        rocketchat/rocket.chat:latest   "node main.js"           3 weeks ago         Up 6 hours          0.0.0.0:3000->3000/tcp   rocket_rocketchat_1_b8ee159f80c3
ea0e49de71ce        mongo:3.2                       "docker-entrypoint..."   3 weeks ago         Up 6 hours          27017/tcp                rocket_mongo_1_6ca5fa0882ca

Prepare, save & load images to another server

# Stop the container 
docker stop rocket_rocketchat_1_b8ee159f80c3
docker stop rocket_mongo_1_6ca5fa0882ca

# Commit a container state to a new image
docker commit rocket_rocketchat_1_b8ee159f80c3 rocket_rocketchat_1
docker commit rocket_mongo_1_6ca5fa0882ca rocket_mongo_1

# Save and load image to another host
docker save rocket_rocketchat_1 | ssh belashev@192.201.0.137 docker load
docker save rocket_mongo_1 | ssh belashev@192.201.0.137 docker load

# Save mongo db storage dir and rocketchat upload dir
# (it's directory where lies docker-compose.yml file)
tar -cf ~/Downloads/$(date +\%Y-\%m-\%d)_rocket.tar rocket

# Move mongo db storage dir and rocketchat upload dir
scp 2019-02-25_rocket.tar.gz belashev@192.201.0.137:~/

Check & run our megrated images on new server

belashev at srv137 in ~
$ docker image list
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
rocket_mongo_1        latest              c8fc13b28a87        38 minutes ago      300MB
rocket_rocketchat_1   latest              5fd85ebf3f5c        38 minutes ago      1.45GB
hello-world           latest              fce289e99eb9        7 weeks ago         1.84kB

tar -xf 2019-02-25_rocket.tar.gz
cd ~/rocket

# change default rocketchat image names on our new image name
# on next values 
# line7:  rocket_rocketchat_1:latest
# line28: rocket_mongo_1:latest
vim docker-compose.yml

# start containers
docker-compose up -d mongo
docker-compose up -d rocketchat
@ae5960e8-a6fc-491f-b252-898ecf59af95

Hi, does this process apply to the latest version of Rocket.Chat? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment