Docker tips and tricks: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
m (Text replacement - "</source" to "</syntaxhighlight")
 
(One intermediate revision by the same user not shown)
Line 25: Line 25:
alias omd-start='docker container run --rm -dit -p 8080:5000 --tmpfs /omd/sites/omd/tmp:uid=1000,gid=1000 --ulimit nofile=1024 -v monitoring:/omd/sites --name monitoring -e CMK_SITE_ID=omd -e MAIL_RELAY_HOST='\''smtp-gw.server.tld'\'' -v /etc/localtime:/etc/localtime:ro checkmk/check-mk-raw:1.6.0p12'
alias omd-start='docker container run --rm -dit -p 8080:5000 --tmpfs /omd/sites/omd/tmp:uid=1000,gid=1000 --ulimit nofile=1024 -v monitoring:/omd/sites --name monitoring -e CMK_SITE_ID=omd -e MAIL_RELAY_HOST='\''smtp-gw.server.tld'\'' -v /etc/localtime:/etc/localtime:ro checkmk/check-mk-raw:1.6.0p12'
alias omd-stop='docker stop $(docker ps --filter name=monitoring -q)'
alias omd-stop='docker stop $(docker ps --filter name=monitoring -q)'
</syntaxhighlight>
== Setting some defaults ==
/etc/docker/daemon.json
<syntaxhighlight lang=json>
{
  "insecure-registries" : ["registry.server.de:5000"],
  "data-root": "/docker-data/",
  "default-address-pools": [
    {
      "scope": "local",
      "base": "10.42.0.0/16",
      "size": 24
    }
  ],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "2m",
    "max-file": "10"
  }
}
</syntaxhighlight>
Or log via systemd journald:
<syntaxhighlight lang=json>
  "log-driver": "journald",
  "log-opts": {
    "tag": "{{.Name}}"
  }
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 16:12, 16 April 2024

Using docker behind a proxy

# systemctl edit docker.service

Enter the next three lines and save:

[Service]
Environment="HTTP_PROXY=user:pass@proxy:port"
Environment="HTTPS_PROXY=user:pass@proxy:port"

Restart docker:

# systemctl restart docker.service

Some useful aliases

I put this in my ~/.bash_aliases to maintain a check_mk container:

alias omd-log='docker container logs monitoring'
alias omd-recreate-volume='docker volume create --driver local --opt type=nfs --opt o=addr=nfs.server.tld,rw --opt device=:/share monitoring'
alias omd-root='docker container exec -it $(docker ps --filter name=monitoring -q) /bin/bash'
alias omd-cmk='docker container exec -it -u omd monitoring bash'
alias omd-start='docker container run --rm -dit -p 8080:5000 --tmpfs /omd/sites/omd/tmp:uid=1000,gid=1000 --ulimit nofile=1024 -v monitoring:/omd/sites --name monitoring -e CMK_SITE_ID=omd -e MAIL_RELAY_HOST='\''smtp-gw.server.tld'\'' -v /etc/localtime:/etc/localtime:ro checkmk/check-mk-raw:1.6.0p12'
alias omd-stop='docker stop $(docker ps --filter name=monitoring -q)'

Setting some defaults

/etc/docker/daemon.json

{
  "insecure-registries" : ["registry.server.de:5000"],
  "data-root": "/docker-data/",
  "default-address-pools": [
    {
      "scope": "local",
      "base": "10.42.0.0/16",
      "size": 24
    }
  ],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "2m",
    "max-file": "10"
  }
}

Or log via systemd journald:

  "log-driver": "journald",
  "log-opts": {
    "tag": "{{.Name}}"
  }