108 lines
2.2 KiB
Markdown
108 lines
2.2 KiB
Markdown
# docker
|
|
|
|
[TOC]
|
|
|
|
## Volumes
|
|
|
|
### NFS
|
|
|
|
Notes:
|
|
|
|
|
|
docker-compose.yaml
|
|
|
|
```yaml
|
|
volumes:
|
|
volume00:
|
|
driver: local
|
|
driver_opts:
|
|
type: ${VOLUME_TYPE}
|
|
o: ${VOLUME_O}
|
|
device: "${VOLUME_DEVICE}"
|
|
```
|
|
|
|
.env
|
|
|
|
```text
|
|
VOLUME_TYPE="nfs"
|
|
|
|
# DNS server ip, RW:read and write
|
|
VOLUME_O="addr=10.10.1.1,rw"
|
|
|
|
# Folder on NFS Server
|
|
## Must exists on nfs server, or security errors when starting container
|
|
VOLUME_DEVICE=":/export/docker-volumes/volume00"
|
|
```
|
|
|
|
## Network
|
|
|
|
### Macvlan
|
|
|
|
#### Create
|
|
|
|
How to create a docker macvlan network
|
|
|
|
```bash
|
|
# run on host
|
|
docker network create -d macvlan --subnet=192.168.1.249/24 --gateway=192.168.1.1 -o parent=eth0 macvlan_network
|
|
```
|
|
|
|
#### Host comunication
|
|
|
|
if network required between host and docker container on a macvlan docker network
|
|
|
|
* Option 1 - Create another macvlan on host
|
|
|
|
* Setup vars
|
|
|
|
```bash
|
|
MACVLAN_NAME=macvlan_bridge
|
|
HOST_ETHERNET_ADP=eth0
|
|
NETWORK=192.168.1.0/24
|
|
```
|
|
|
|
* Create mavclan adapter
|
|
|
|
```bash
|
|
ip link add $MACVLAN_NAME link $HOST_ETHERNET_ADP type macvlan mode bridge
|
|
ip addr add $NETWORK dev $MACVLAN_NAME
|
|
ifconfig $MACVLAN_NAME up
|
|
```
|
|
|
|
* Add routing
|
|
|
|
```bash
|
|
ip route add $CONTAINER_MAVLAN_IP dev $MACVLAN_NAME
|
|
```
|
|
|
|
* Delete mavclan adapter
|
|
|
|
```bash
|
|
ifconfig $MACVLAN_NAME down
|
|
ip link del $MACVLAN_NAME
|
|
```
|
|
|
|
* Persisting macvlan configuration
|
|
Example:
|
|
* network: 192.168.1.0/24
|
|
* macvlan name:: macvlan_bridge
|
|
* macvlan static ip: 192.168.1.240/32
|
|
* docker containers on macvlan networks:
|
|
* 192.168.1.254
|
|
* 192.168.1.253
|
|
* 192.168.1.250
|
|
* 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
|
|
```
|