I do have the following problem: I have a docker image of an home-automation system which comprises a lot of Services like: MQTT Service, Web-Interface, WebServer etc. so it uses a lot of ports and I did set it up in an MACVLAN container with a dedicated IP-Address to not expose all the ports on the physical host.
Now this service would love to use Redis as in Memory Cache, so I added another Service to my compose file and was almost fine excepts that I actually want redis to be exposed via the same IP as the home-automation system.
On a virtual machine or as "merged docker" image this would not be a problem: Install OS, install home-automation and redis or deploy it within one docker image.
It would also not be an issue if I would use bridge mode network and expose all ports on the host, but I prefer having a dedicated IP.
This is how far I got but Redis is of course not accessible via the MACVLAN_IP of the home-automation-system
version: '3.5'
services:
iobroker:
container_name: iobroker
image: buanet/iobroker
hostname: iobroker
restart: unless-stopped
#ports > Not explicitly exposed as on MACVLAN it creates a virtual host
environment:
- IOB_STATESDB_HOST=iobroker-redis
- IOB_STATESDB_PORT=6379
- IOB_STATESDB_TYPE=redis
volumes:
- ....
depends_on:
- redis
networks:
my-macvlan:
ipv4_address: 192.168.177.6
my-bridgenetwork:
redis:
container_name: iobroker-redis
image: redis:latest
hostname: redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- ....
command: redis-server /usr/local/etc/redis/redis.conf
networks:
my-bridgenetwork:
networks:
my-macvlan:
external: true
my-bridgenetwork:
external: true
any ideas how I could get redis to be accessible on the MACVLAN-IP 192.168.177.6 in my example?
I already tried using
network_mode: service: iobroker
for the redis-service but this is not working as it create a cycle as the redis container seems to require, that the underlying service container was started but the service container itself relies on redis.
I read that you could create a "parent container" acting as a host for the MACVLAN IP and then adding two containers in "network mode container" but I could not find any example for it.