I have a container that uses the host network with the option network_mode: host.
Then I created two additional containers and an internal network. Both for itself works, but if I add the first container to the network, it collides with:
ERROR: 'network_mode' and 'networks' cannot be combined
When using the option ports:, the container is not accessible from the host network.
What is an easy way got get the container to be a member of internal network and host network without additional routing? I currently use macvlan and that works so far but it requires an additional IP address which is not the main problem but would be better if it could use the main stack.
Here the docker-compose.yml
version: '3.8'
services:
ros-master:
image: ros-master:latest
build:
context: ./ros-master
container_name: ros-master-testing
# network_mode: host
# ports:
# - "7400-7500:7400-7500"
networks:
# - ros-backend
ros-backend: {}
macvlan-network:
ipv4_address: 192.168.201.116
devices:
- /dev/bus/usb:/dev/bus/usb # full USB passthrough
- /dev/ttyACM0:/dev/ttyACM0
- /dev/ttyACM1:/dev/ttyACM1
- /dev/video0:/dev/video0
- /dev/video1:/dev/video1
volumes:
- ./ros_master_workspace:/workspace
restart: always
privileged: true
ros-slave:
image: ros-slave:latest
build:
context: ./ros-slave
container_name: ros-slave-testing
# network_mode: host
networks:
- ros-backend
restart: unless-stopped
ros-bridge:
image: ros-bridge:latest
build:
context: ./ros-bridge
container_name: ros-bridge-testing
# network_mode: host
networks:
- ros-backend
restart: unless-stopped
networks:
default:
external:
name: host
ros-backend:
driver: bridge
macvlan-network:
driver: macvlan
driver_opts:
parent: eth0
ipam:
config:
- subnet: "192.168.201.0/24"
gateway: "192.168.201.254"
ip_range: "192.168.201.0/24"
not important I think but btw:
ros-master = humble
ros-bridge = galactic + noetic
my problem now is:
container ros-master works so far, I can see the topics from ros-bridge and the external, over lan, published topics.
ros-bridge cannot see the external topics (which is currently not the problem, but it should see them, since they are on the same network) but also cannot see the topics published by ros-master.