目前使用的是这样的配置
docker compose 启动后 curl 可以用 192.168.3.65 访问 nginx
但是 host 和其他 container 无法访问 192.168.3.65 ,使用了
https://forums.docker.com/t/can-reach-container-on-macvlan-from-host-but-not-from-rest-of-network/106817 中的最后 4 条命令 container 里就能看到了
目前还有两个问题
1. curl 失去了 internet 的访问 我哪里配置错了吗?
2. 关于 4 条命令的持久化,除了 crontab 还有更优雅的方式吗?
```bash
ip link add vlan10-shim link ens160 type macvlan mode bridge
ip addr add <MACVLAN ip>/32 dev vlan10-shim
ip link set vlan10-shim up
ip route add 192.168.10.0/25 dev vlan10-shim
```
```yaml
services:
nginx:
image: nginx
container_name: nginx
networks:
vlan:
ipv4_address: 192.168.3.65
mac_address: "ca:75:45:11:33:92"
curl:
image: curlimages/curl-base
command: "sleep 3600"
container_name: curl
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
vlan:
ipv4_address: 192.168.3.66
mac_address: "ca:75:45:11:33:93"
networks:
vlan:
driver: macvlan
driver_opts:
parent: qvs0
macvlan_mode: bridge
ipam:
config:
- subnet: 192.168.3.0/24
gateway: 192.168.3.1
ip_range: "192.168.3.64/26"
aux_addresses:
host: 192.168.3.67
```