Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
2023-09-28 21:33:43 +01:00

226
README.md
View File

@@ -1,107 +1,119 @@
# docker # docker
[TOC] ## Setup
## Volumes ### Alphine
source https://wiki.alpinelinux.org/wiki/Docker
### NFS
```bash
Notes: apk add docker
addgroup username docker
rc-update add docker default
docker-compose.yaml service docker start
```yaml ```
volumes:
volume00:
driver: local ## Volumes
driver_opts:
type: ${VOLUME_TYPE} ### NFS
o: ${VOLUME_O}
device: "${VOLUME_DEVICE}" Notes:
```
.env docker-compose.yaml
```text ```yaml
VOLUME_TYPE="nfs" volumes:
volume00:
# DNS server ip, RW:read and write driver: local
VOLUME_O="addr=10.10.1.1,rw" driver_opts:
type: ${VOLUME_TYPE}
# Folder on NFS Server o: ${VOLUME_O}
## Must exists on nfs server, or security errors when starting container device: "${VOLUME_DEVICE}"
VOLUME_DEVICE=":/export/docker-volumes/volume00" ```
```
.env
## Network
```text
### Macvlan VOLUME_TYPE="nfs"
#### Create # DNS server ip, RW:read and write
VOLUME_O="addr=10.10.1.1,rw"
How to create a docker macvlan network
# Folder on NFS Server
```bash ## Must exists on nfs server, or security errors when starting container
# run on host VOLUME_DEVICE=":/export/docker-volumes/volume00"
docker network create -d macvlan --subnet=192.168.1.249/24 --gateway=192.168.1.1 -o parent=eth0 macvlan_network ```
```
## Network
#### Host comunication
### Macvlan
if network required between host and docker container on a macvlan docker network
#### Create
* Option 1 - Create another macvlan on host
How to create a docker macvlan network
* Setup vars
```bash
```bash # run on host
MACVLAN_NAME=macvlan_bridge docker network create -d macvlan --subnet=192.168.1.249/24 --gateway=192.168.1.1 -o parent=eth0 macvlan_network
HOST_ETHERNET_ADP=eth0 ```
NETWORK=192.168.1.0/24
``` #### Host comunication
* Create mavclan adapter if network required between host and docker container on a macvlan docker network
```bash * Option 1 - Create another macvlan on host
ip link add $MACVLAN_NAME link $HOST_ETHERNET_ADP type macvlan mode bridge
ip addr add $NETWORK dev $MACVLAN_NAME * Setup vars
ifconfig $MACVLAN_NAME up
``` ```bash
MACVLAN_NAME=macvlan_bridge
* Add routing HOST_ETHERNET_ADP=eth0
NETWORK=192.168.1.0/24
```bash ```
ip route add $CONTAINER_MAVLAN_IP dev $MACVLAN_NAME
``` * Create mavclan adapter
* Delete mavclan adapter ```bash
ip link add $MACVLAN_NAME link $HOST_ETHERNET_ADP type macvlan mode bridge
```bash ip addr add $NETWORK dev $MACVLAN_NAME
ifconfig $MACVLAN_NAME down ifconfig $MACVLAN_NAME up
ip link del $MACVLAN_NAME ```
```
* Add routing
* Persisting macvlan configuration
Example: ```bash
* network: 192.168.1.0/24 ip route add $CONTAINER_MAVLAN_IP dev $MACVLAN_NAME
* macvlan name:: macvlan_bridge ```
* macvlan static ip: 192.168.1.240/32
* docker containers on macvlan networks: * Delete mavclan adapter
* 192.168.1.254
* 192.168.1.253 ```bash
* 192.168.1.250 ifconfig $MACVLAN_NAME down
* 192.168.1.248 ip link del $MACVLAN_NAME
```
```text
# create/edit /etc/network/interfaces.d/macvlan_bridge * Persisting macvlan configuration
iface macvlan_bridge inet manual Example:
pre-up ip link add macvlan_bridge link eth0 type macvlan mode bridge * network: 192.168.1.0/24
pre-up ip addr add 192.168.1.240/32 dev macvlan_bridge * macvlan name:: macvlan_bridge
up ip link set macvlan_bridge up * macvlan static ip: 192.168.1.240/32
post-up ip route add 192.168.1.254 dev macvlan_bridge * docker containers on macvlan networks:
post-up ip route add 192.168.1.253 dev macvlan_bridge * 192.168.1.254
post-up ip route add 192.168.1.252 dev macvlan_bridge * 192.168.1.253
post-up ip route add 192.168.1.250 dev macvlan_bridge * 192.168.1.250
post-up ip route add 192.168.1.248 dev macvlan_bridge * 192.168.1.248
```
```text
# create/edit /etc/network/interfaces.d/macvlan_bridge
iface macvlan_bridge inet manual
pre-up ip link add macvlan_bridge link eth0 type macvlan mode bridge
pre-up ip addr add 192.168.1.240/32 dev macvlan_bridge
up ip link set macvlan_bridge up
post-up ip route add 192.168.1.254 dev macvlan_bridge
post-up ip route add 192.168.1.253 dev macvlan_bridge
post-up ip route add 192.168.1.252 dev macvlan_bridge
post-up ip route add 192.168.1.250 dev macvlan_bridge
post-up ip route add 192.168.1.248 dev macvlan_bridge
```