Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| docker_notes:docker [2024-01-14 Sun wk02 11:23] – baumkp | docker_notes:docker [2026-01-17 Sat wk03 09:03] (current) – [Docker CLI] baumkp | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{tag> | + | {{tag> |
| - | Much of this material was originally sourced from: [[https:// | + | |
| ======Docker====== | ======Docker====== | ||
| Line 10: | Line 8: | ||
| =====Installation===== | =====Installation===== | ||
| + | *[[https:// | ||
| One click installation script: | One click installation script: | ||
| *'' | *'' | ||
| Line 22: | Line 20: | ||
| Install Docker Engine : [Docker Engine](https:// | Install Docker Engine : [Docker Engine](https:// | ||
| + | |||
| + | ====downgrade docker==== | ||
| + | The upgrade of docker-ce from version 28.5.2 to 29.0.0 seems to have broken something and the environment stopped function correctly, seems to be docker-ce and traefik related, both packages seem to have been fixed about 3 days later. | ||
| + | For debian based systems: | ||
| + | *'' | ||
| + | *< | ||
| + | Installed: 5: | ||
| + | Candidate: 5: | ||
| + | Version table: | ||
| + | *** 5: | ||
| + | 500 https:// | ||
| + | 100 / | ||
| + | | ||
| + | 500 https:// | ||
| + | | ||
| + | 500 https:// | ||
| + | | ||
| + | *'' | ||
| + | |||
| + | This problem keeps on giving. | ||
| + | ++++sudo systemctl edit docker.service| | ||
| + | < | ||
| + | Environment=DOCKER_MIN_API_VERSION=1.24</ | ||
| + | And then '' | ||
| + | ++++ | ||
| + | Presumably this will eventually be resolved up stream and this fix can be removed. | ||
| + | |||
| + | Some references to assist with this: | ||
| + | *[[https:// | ||
| + | *'' | ||
| + | *'' | ||
| + | *[[https:// | ||
| + | *'' | ||
| + | *'' | ||
| + | *'' | ||
| + | *[[https:// | ||
| + | *'' | ||
| + | *'' | ||
| + | ====Docker Desktop for Linux==== | ||
| + | I have preferred to run Docker command as a native Linux applications. | ||
| =====Uninstall===== | =====Uninstall===== | ||
| Both the install methods actually use the standard package manager to install docker. | Both the install methods actually use the standard package manager to install docker. | ||
| - | -'' | + | -'' |
| -'' | -'' | ||
| -Check the the '' | -Check the the '' | ||
| Line 31: | Line 69: | ||
| *[[https:// | *[[https:// | ||
| - | =====Docker and iptables===== | + | =====Docker and iptables |
| Docker applies iptables on the host machine, see [[https:// | Docker applies iptables on the host machine, see [[https:// | ||
| Line 38: | Line 76: | ||
| ++++For some more details, tldr;|This may affect other services operating on the host machine. | ++++For some more details, tldr;|This may affect other services operating on the host machine. | ||
| - | Linux forwarding is required for Docker and can be checked with '' | + | Linux forwarding is required for Docker and can be checked with '' |
| It would also adversely affect my Linux router should I attempt to load docker on this machine. | It would also adversely affect my Linux router should I attempt to load docker on this machine. | ||
| Line 64: | Line 102: | ||
| ++++ | ++++ | ||
| + | |||
| + | =====DNS and nftable / iptables / netfilter within containers===== | ||
| + | Docker has to perform some interesting network filtering both on the container host, as noted above and within containers as outlined here. It looks like this is required to allow container DNS functionality on Docker containers using bridge networking. | ||
| + | |||
| + | The containers DNS (''/ | ||
| + | |||
| + | Further to this The container netfilter use NAT chains to operate on 127.0.0.11. | ||
| + | ++++nft list tables| | ||
| + | < | ||
| + | ++++ | ||
| + | ++++nft list table ip nat| | ||
| + | <code bash nft.conf># | ||
| + | table ip nat { | ||
| + | chain DOCKER_OUTPUT { | ||
| + | meta l4proto tcp ip daddr 127.0.0.11 xt match " | ||
| + | meta l4proto udp ip daddr 127.0.0.11 xt match " | ||
| + | } | ||
| + | |||
| + | chain OUTPUT { | ||
| + | type nat hook output priority dstnat; policy accept; | ||
| + | ip daddr 127.0.0.11 counter packets 329 bytes 20249 jump DOCKER_OUTPUT | ||
| + | } | ||
| + | |||
| + | chain DOCKER_POSTROUTING { | ||
| + | meta l4proto tcp ip saddr 127.0.0.11 xt match " | ||
| + | meta l4proto udp ip saddr 127.0.0.11 xt match " | ||
| + | } | ||
| + | |||
| + | chain POSTROUTING { | ||
| + | type nat hook postrouting priority srcnat; policy accept; | ||
| + | ip daddr 127.0.0.11 counter packets 329 bytes 20249 jump DOCKER_POSTROUTING | ||
| + | } | ||
| + | } | ||
| + | / # </ | ||
| + | ++++ | ||
| + | |||
| + | On VPN setup, at least openvpn, the / | ||
| + | |||
| + | On the other hand where Docker bridge network DNS container name resolution is desirable then these netfilter chains must basically remain unadulterated. | ||
| + | | ||
| =====Portainer===== | =====Portainer===== | ||
| Line 80: | Line 158: | ||
| =====Portainer agent===== | =====Portainer agent===== | ||
| + | Running Portainer agent from docker is a tedious. | ||
| + | ++++docker agent docker compose, | ||
| + | <code yaml> | ||
| + | services: | ||
| + | |||
| + | portainer-agent: | ||
| + | container_name: | ||
| + | image: portainer/ | ||
| + | ports: | ||
| + | - " | ||
| + | volumes: | ||
| + | # Mount the host's Docker socket into the container | ||
| + | - / | ||
| + | # Mount the host's Docker volumes into the container | ||
| + | - / | ||
| + | deploy: | ||
| + | resources: | ||
| + | limits: | ||
| + | cpus: ' | ||
| + | memory: 1024M | ||
| + | restart_policy: | ||
| + | condition: unless-stopped | ||
| + | delay: 5s | ||
| + | window: 120s</ | ||
| + | ++++ | ||
| + | |||
| + | ++++run docker agent from docker| | ||
| Portainer agent allows a remote docker machine to be seen else were via the network. | Portainer agent allows a remote docker machine to be seen else were via the network. | ||
| * First stop the agent container: '' | * First stop the agent container: '' | ||
| * Then remove the agent container: '' | * Then remove the agent container: '' | ||
| * Then pull the latest portainer/ | * Then pull the latest portainer/ | ||
| - | <code yaml> | + | <code yaml> |
| - | -v / | + | ++++ |
| - | -v / | + | It would seem remote agents by default do not show out of date images, can be toggled on/off under '' |
| - | portainer/ | + | |
| - | =====Build Images===== | ||
| =====Docker CLI===== | =====Docker CLI===== | ||
| + | Much of this material was originally sourced from: [[https:// | ||
| **Run Containers** | **Run Containers** | ||
| Line 142: | Line 247: | ||
| |'' | |'' | ||
| |'' | |'' | ||
| - | |'' | + | |'' |
| - | |'' | + | |'' |
| **Inspect / Troubleshoot Containers: | **Inspect / Troubleshoot Containers: | ||
| - | |<38em>| | + | |<56em>| |
| ^COMMAND ^ DESCRIPTION^ | ^COMMAND ^ DESCRIPTION^ | ||
| |'' | |'' | ||
| Line 157: | Line 262: | ||
| |'' | |'' | ||
| |'' | |'' | ||
| + | |'' | ||
| + | |'' | ||
| **Run Commands:** | **Run Commands:** | ||
| Line 170: | Line 277: | ||
| **Images:** | **Images:** | ||
| - | |<35em>| | + | |<40em>| |
| ^COMMAND ^ DESCRIPTION^ | ^COMMAND ^ DESCRIPTION^ | ||
| |'' | |'' | ||
| Line 189: | Line 296: | ||
| **Volumes: | **Volumes: | ||
| - | |<50em>| | + | |<55em>| |
| ^COMMAND ^ DESCRIPTION^ | ^COMMAND ^ DESCRIPTION^ | ||
| |'' | |'' | ||
| Line 196: | Line 303: | ||
| |'' | |'' | ||
| |'' | |'' | ||
| - | |'' | + | |'' |
| + | |||
| + | **Network: | ||
| + | |< | ||
| + | ^COMMAND ^ DESCRIPTION^ | ||
| + | |'' | ||
| + | |'' | ||
| + | |'' | ||
| + | |'' | ||
| + | |'' | ||
| + | |'' | ||
| + | |||
| + | =====DOCKER DNS===== | ||
| + | Docker has an internal DNS for each discrete type network. | ||
| + | ====docker ps command==== | ||
| + | The '' | ||
| + | *'' | ||
| + | < | ||
| + | *'' | ||
| + | < | ||
| + | *'' | ||
| + | < | ||
| + | ===reference=== | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | *Docker Docs | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| ====Backup a container==== | ====Backup a container==== | ||
| Backup docker data from inside container volumes and package it in a tarball archive.\\ | Backup docker data from inside container volumes and package it in a tarball archive.\\ | ||
| Line 221: | Line 355: | ||
| * '' | * '' | ||
| - Host (Appears on the host machine as if installed there, no separate network.) | - Host (Appears on the host machine as if installed there, no separate network.) | ||
| - | | + | -If you use the host network mode for a container, that container' |
| + | | ||
| + | -The macvlan network assigns a unique MAC address to each container, making it appear to be a physical device on your network, just like a traditional virtual machine. The Docker daemon then routes the traffic to containers on the basis of their MAC address. It also allows you to assign an IP address from the same subnet in which the Docker host resides. This avoids the use of the host network, there is no NAT overhead, and you won't run into network performance issues. | ||
| - MACVLAN (without subVLAN) this create a new ip address on the host machine | - MACVLAN (without subVLAN) this create a new ip address on the host machine | ||
| - | * <code bash> | + | * <code bash> |
| + | -d macvlan \ | ||
| --subnet 192.168.1.0/ | --subnet 192.168.1.0/ | ||
| --gateway 192.168.1.1 \ | --gateway 192.168.1.1 \ | ||
| - | -o parent=br0 | + | -o parent=br0 network_named</ |
| - | network_named</ | + | |
| * No host DHCP access so need to specify ip address when creating container (docker cli '' | * No host DHCP access so need to specify ip address when creating container (docker cli '' | ||
| * May be problem with multiple MACs on common switch port. Need to set promiscuous mode on network, e.g. '' | * May be problem with multiple MACs on common switch port. Need to set promiscuous mode on network, e.g. '' | ||
| Line 233: | Line 369: | ||
| - IPVLAN | - IPVLAN | ||
| - IPVLAN on host subnet, this create a new ip address on the host machine, but not with new MAC number, it uses the host MAC number | - IPVLAN on host subnet, this create a new ip address on the host machine, but not with new MAC number, it uses the host MAC number | ||
| - | * <code bash> | + | * <code bash> |
| + | -d ipvlan \ | ||
| --subnet 192.168.1.0/ | --subnet 192.168.1.0/ | ||
| --gateway 192.168.1.1 \ | --gateway 192.168.1.1 \ | ||
| - | -o parent=br0 | + | -o parent=br0 network_named</ |
| - | network_named</ | + | |
| * No host DHCP access so need to specify ip address when creating container (docker cli '' | * No host DHCP access so need to specify ip address when creating container (docker cli '' | ||
| * May be problem with shared MAC with multiple IP address, but less likely than MACVLAN. | * May be problem with shared MAC with multiple IP address, but less likely than MACVLAN. | ||
| - IPVLAN on separate subnet using the host machine as gateway, but not with new MAC number, it uses the host MAC number | - IPVLAN on separate subnet using the host machine as gateway, but not with new MAC number, it uses the host MAC number | ||
| - | * <code bash> | + | * <code bash> |
| + | -d ipvlan \ | ||
| --subnet 192.168.1.0/ | --subnet 192.168.1.0/ | ||
| -o parent=br0 -o ipvlan_mode=l3 \ | -o parent=br0 -o ipvlan_mode=l3 \ | ||
| - | --subnet 192.168.10.0/ | + | --subnet 192.168.10.0/ |
| - | network_named</ | + | |
| * No host DHCP access so need to specify ip address when creating container (docker cli '' | * No host DHCP access so need to specify ip address when creating container (docker cli '' | ||
| * May be problem with shared MAC with multiple IP address, but less likely than MACVLAN. | * May be problem with shared MAC with multiple IP address, but less likely than MACVLAN. | ||
| - Overlay network, an even more obscure network arrangement I know nothing about. | - Overlay network, an even more obscure network arrangement I know nothing about. | ||
| - None network - no assigned network, container has no external network connectivity | - None network - no assigned network, container has no external network connectivity | ||
| - | ====Troubleshooting==== | + | |
| + | ====References==== | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | |||
| + | =====Docker IP6===== | ||
| + | |||
| + | ====References==== | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | =====network troubleshooting===== | ||
| + | A lot of containers are setup to be small and hence do not include many, if any of the tools required to diagnose problems. | ||
| + | *'' | ||
| + | |||
| + | |||
| + | ====Network | ||
| *[[https:// | *[[https:// | ||
| *[[https:// | *[[https:// | ||
| + | |||
| + | =====Docker Container Repositories===== | ||
| + | |||
| + | ====References==== | ||
| + | *[[https:// | ||
| + | *[[https:// | ||
| + | |||
| + | |||
| + | =====Docker Cleanup===== | ||
| + | Docker can take a lot of disk space. | ||
| + | Docker stores the container images and other operating information in ''/ | ||
| + | *'' | ||
| + | *'' | ||
| + | |||
| <- docker_notes: | <- docker_notes: | ||