docker save image:latest | bzip2 > myimage_latest.tar.bz2
docker load < myimage_latest.tar.bz2
Setup a mongodb docker container
docker pull mongodb:5.0
mkdir ~/mongodb
cp init-mongo.js ~/mongodb
Export a database from a docker container to a flat file that can then be used to import in another docker container (basically transferring a database from on server to another)
docker exec <mongodb container> sh -c 'mongodump --authenticationDatabase admin -u <user> -p <password> --db <database> --archive' > db.dump
Import a database that was exported from another docker container
docker exec -i <mongodb container> sh -c 'mongorestore --authenticationDatabase admin -u <user> -p <password> --db <database> --archive' < db.dump
To get to the mongo shell in a docker container. Assumption is the docker container is up and running
docker exec -it mongodb /bin/sh
mongo -u <user> <database>
The URI needed to connect to the mongo database. The example below is for fish shell
set -x MONGODB_URI mongodb://<user>:<pass>@<host>:27017/<db_name>
Using diff
to create create/apply patches
Create patch by running the following
diff -u OriginalFile UpdatedFile > PatchFile
Assume you have a directory with some files and subdirectories inside. You recursively copy its content to some new directory and do the necessary updates in it. To create a patch file containing the modifications you’ve made, run the following command:
diff -ruN OriginalDir UpdatedDir > PatchFile
Run the following to apply the patch
patch OriginalFile < PatchFile
For a directory, run this:
patch -p0 < PatchFile
To undo a patch, run the following
patch -R OriginalFile < PatchFile
To undo for a directory, run this:
patch -R -p0 OriginalFile < PatchFile
Some shortcuts and keybindings that are out of the box from emacs for org-mode
<s<tab>
<e<tab>
shift+tab will cycle through folding/expanding everything
use :toc: