====== Docker ======
===== Docker Registry Proxy =====
https://docs.docker.com/config/daemon/systemd/#httphttps-proxy
===== Bootstrap basic Debian image =====
mkdir jessie-chroot
sudo debootstrap jessie ./jessie-chroot http://http.debian.net/debian/
Build docker image from tarball
cd jessie-chroot
sudo tar cpf - . | docker import - debian
Build new container
docker run -it --rm debian /bin/bash
===== Start Container from Dockerhub Image =====
docker run --name nifi -p 8080:8080 -d apache/nifi:latest
With interactive shell:
docker run -it apache/nifi bash
===== Jump into Container =====
docker exec -it nifi bash
===== Stop Container =====
docker stop nifi
===== Remove Containers, Images, Volumes =====
docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker rmi $(docker images -aq) && docker volume rm $(docker volume ls -q)
===== Aliases =====
//(Docker aliases to set for the shell)//
alias dps='docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.Image}}\t{{.Command}}" | (read -r; printf "%s\n" "$REPLY"; sort -k 1 )'
===== Docker Logging =====
====== Logging with rsyslog ======
/etc/rsyslog.d/docker.conf
# Docker config
$AddUnixListenSocket /tmp/syslog.sock
# syslogtag enthält noch PID
# programname nur appname/tag: 598-rddnsmasq
$template myFormat,"%timereported% %programname%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
template(
name="docker_container_file"
type="string"
string="/var/log/docker/%programname%.log"
option.casesensitive="on"
)
# 23: local7
if $syslogfacility == 23 then {
if $programname startswith "bw_" then {
action(name="docker-containers-bitwarden" type="omfile" file="/var/log/docker/bitwarden.log" template="myFormat")
} else {
action(name="docker-containers" type="omfile" dynaFile="docker_container_file" template="myFormat")
}
}
/etc/docker/daemon.json
{
"log-driver": "syslog",
"log-opts":
{
"tag": "{{.Name}}",
"syslog-facility": "local7",
"syslog-address": "unixgram:///tmp/syslog.sock"
}
}
Restart rsyslog, the docker daemon and then all containers to switch to the new driver. Otherwise the docker daemon shows the following error message for the affected containers: "Configured log driver does not support reads, enabling local file cache for container logs".