Skip to content

Instantly share code, notes, and snippets.

@ryanjohnston
Last active September 9, 2018 18:45
Show Gist options
  • Save ryanjohnston/8d7b695b529e0da3c2ba669259b06554 to your computer and use it in GitHub Desktop.
Save ryanjohnston/8d7b695b529e0da3c2ba669259b06554 to your computer and use it in GitHub Desktop.
[Docker - Info ] Information about using Docker

Backup Named Volume

How I backup named volumes.

  • Using a ubuntu image, we mount the named volume (myproj_dbdata) to a /dbdata folder inside the ubuntu container.
  • Create a new folder inside the ubuntu container named /backup.
  • Create an archive containing the contents of the /dbdata folder and we store it inside the /backup folder (inside the container).
  • Mount the /backup folder from the container to the docker host (your local machine) in a folder named /backups inside the current directory.

docker run --rm -v myproj_dbdata:/dbdata -v $(pwd)/backups:/backup ubuntu tar cvf /backup/db_data_"$(date '+%y-%m-%d')".tar /dbdata

Docker Run Examples

Table of Contents

NPM

From the same directory where your gulpfile is located, install all the node modules for the project first:

$ docker run --rm --name node -v `pwd`:`pwd` -w `pwd` node npm install

Gulp

From the same directory, you can also use docker to run gulp. For example:

$ docker run --rm --name node -v `pwd`:`pwd` -w `pwd` node ./node_modules/.bin/gulp sass

Docker

Table of Contents

#!/usr/bin/env bash
#
# Free dynamic DNS service
#
# Requires the following global values to be defined elsewhere:
#
# DUCKDNS_TOKEN - Get this from your account page at DuckDNS.
# PGID - Your users GID
# PUID - Your users UID
# SUBDOMAINS - Get this from your account page at DuckDNS.
# TZ - Your timezone (ex. "America/Edmonton")
#
# Create container
#
duckdns_create() {
docker create \
--name=duckdns \
-e "PGID=$PGID" \
-e "PUID=$PUID" \
-e "SUBDOMAINS=$SUBDOMAINS" \
-e "TOKEN=$DUCKDNS_TOKEN" \
-e "TZ=$TZ" \
linuxserver/duckdns
}
#
# Run container
#
duckdns() {
docker start duckdns
}
#
# View logs
#
duckdns_logs() {
docker logs -f duckdns
}
#
# Save container locally
#
duckdns_save() {
docker commit \
--author "$AUTHOR" \
duckdns \
ryanjohnston/duckdns:latest
}
!/usr/bin/env bash
docker run -v /data:/data -p 8000:8000 dwmkerr/dynamodb -dbPath /data -sharedDb
open http://localhost:8000/shell
#!/usr/bin/env zsh
traefik () {
local CONFIG="/mnt/raid/data/traefik/traefik.toml"
local ACME="/mnt/raid/data/traefik/acme.json"
docker run -d \
--restart=always \
--name traefik \
-p 8080:8080 -p 443:443 -p 80:80 \
--network=docker \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$CONFIG:/traefik.toml" \
-v "$ACME:/acme.json" \
traefik:alpine
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment