Can't restore previous data after update - docker

After updating my thingsboard docker image from v2.4.0 to v2.4.1, the new thingsboard container doesn't have any of my previous data, in my host dir I have the ~/.mytb-data directory with 8Gb of size, there is a way to restore that data to my container or another database, I really need to get that data from ~/.mytb-data
This is the docker image that I using: thingsboard/tb-cassandra
The update process:
$ docker pull thingsboard/tb-cassandra
$ docker stop mytb
$ docker run -it -v ~/.mytb-data:/data --rm thingsboard/tb-cassandra upgrade-tb.sh
$ docker rm mytb
$ docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -v ~/.mytb-data:/data -v ~/.mytb-logs:/var/log/thingsboard --name mytb --restart always thingsboard/tb-cassandra

Related

What is preventing file persistence when using a Docker volume?

I have a Docker image named pfa-image (contains a fairly basic Express-based website), a running mongoDB container named pfa-mongo, and a docker volume named image-volume. When I run the following sequence of commands..:
host$ docker run -d --name pfa-container -v image-volume:/images \
--link pfa-mongo:mongodb -p 5000:5000 pfa-image
host$ docker exec -it pfa-container /bin/bash
container:/pfa-site# cd images
container:/pfa-site/images# touch test.txt
container:/pfa-site/images# exit
host$ docker rm -f pfa-container
host$ docker run -d --name pfa-container -v image-volume:/images \
--link pfa-mongo:mongodb -p 5000:5000 pfa-image
host$ docker exec -it pfa-container /bin/bash
container:/pfa-site# cd images
container:/pfa-site/images# ls
...test.txt is missing. What am I overlooking here? I am quite new to docker and somewhat new to Linux.
Thank you!
I have tried using bind mounts and volumes, to the same result.

How to create a Debian docker container that can run docker containers?

I need a Debian container that can run containers itself (and has access to systemd). Following this post, I have tried to run
docker run -v /var/run/docker.sock:/var/run/docker.sock --name debian-buster-slim -h 10-slim -e LANG=C.UTF-8 -it debian:10-slim /bin/bash -l
but the container cannot run docker containers. What am I doing wrong?

Unable to backup docker volumne

I'm following the offical docker guide from here to backup a docker volume. I'm also aware of this SO question however I'm still running into errors. Running the following command:
docker run --rm --volumes-from dbstore -v $(pwd):/backup ny_db_1 tar cvf /backup/backup.tar /dbdata
No matter what image name or container name or container id I put, I get the following error:
Unable to find image 'ny_db_1:latest' locally
The volume I want to backup:
$ docker volume ls
DRIVER VOLUME NAME
local ny_postgres_data
My containers:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
39e71e660eda postgres:10.1-alpine "docker-entrypoint.s…" 4 days ago Up 23 minutes 0.0.0.0:5434->5433/tcp ny_db_1
How do I backup my volume?
Update:
I tried the following but ran into a new error:
$ docker run --rm --volumes-from 39e71e660eda -v $(pwd):/backup postgres:10.1-alpine tar:local cvf /backup/backup.tar /dbdata
/usr/local/bin/docker-entrypoint.sh: line 145: exec: tar:local: not found
The docker run syntax is docker run [OPTIONS] IMAGE[:TAG|#DIGEST] [COMMAND] [ARG...] - ny_db_1 is the name of your container, docker will attempt to use the IMAGE "ny_db_1" which does not exist hence the error: "Unable to find image 'ny_db_1:latest' locally" (latest is the default [:TAG] if none is specified).
--volumes-from will mount volumes from the specified container(s) into a new container spawned from IMAGE[:TAG] for example: docker run --rm --volumes-from db -v $(pwd):/backup ubuntu:18.04 tar czvf /backup/backup.tar /dbdata
Note: if you're backing up a PostgreSQL database then imho you'd be better off using the appropriate tools to backup and restore the database for example:
Backup using pg_dumpall:
docker run --rm \
--name db-backup \
--entrypoint pg_dumpall \
--volume ${PWD}/backup:/backup \
--volumes-from db \
postgres:9 --host /var/run/postgresql --username postgres --clean --oids --file /backup/db.dump
Restore using psql:
docker run --rm -it \
-v ${PWD}/backup:/restore \
--name restore \
postgres:10.1-alpine
docker exec restore psql \
--host /var/run/postgresql \
--username postgres \
--file /restore/db.dump postgres
docker rename restore NEW_NAME
try this command here:
docker run -it --rm -v ny_postgres_data:/volume -v /tmp:/backup ny_db_1 \
tar -cjf /backup/ny_postgres_data -C /volume ./

Docker: tendermint container not work

My OS is Windows 10 and docker version 17.12.0-ce, build c97c6d6.
Here is my plan:
0. Get containers
docker pull tendermint/tendermint
docker pull tendermint/monitor
1. Init container
docker run --rm -p 46657:46657 --name tendermint_bc -v "C:/Users/user/sandbox/tendermind/tmdata:/tendermint" tendermint/tendermint init
2. Start container
docker run --rm -d -v "C:/Users/user/sandbox/tendermind/tmdata:/tendermint" tendermint/tendermint node --proxy_app=dummy
3. Start tendemint monitor
docker run -it --rm --link=tm tendermint/monitor tendermint_bc:46657
By start of tendermint container I see only one hash, but by docker ps -a container is not listed.
If I run docker logs tendermint_bc, result is:
Error response from daemon: No such container: tendermint_bc
Same workflow on Unix work fine.
Thx for help.
In step 1, you are initializing Tendermint, but not running it. To run it, execute:
docker run --rm -p 46657:46657 --name tendermint_bc -v "C:/Users/user/sandbox/tendermind/tmdata:/tendermint" tendermint/tendermint node --proxy_app=dummy

Docker start a fresh instance(without the user data) of a stopped/running docker container.

Is there a way to start a fresh instance(i.e. without having any user related data from the previous run) of a container without actually removing it and then reissuing the same command.
For example:
$ docker run --name some-redis -p 6379:6379 -d redis
$ docker stop some-redis && docker start some-redis
or $ docker restart some-redis
will restart the container, but the user data from the previous run will persist. Whereas I am looking for an equivalent of the following:
$ docker run --name some-redis -p 6379:6379 -d redis
$ docker stop some-redis && docker rm some-redis
$ docker run --name some-redis -p 6379:6379 -d redis

Resources