I am entirely new to docker so please forgive my ignorance. I did some searching and attempted adding drivers and networks to my docker compose to no avail. Basically, I need at a minimum one docker container to have a static IP within the bridged network so that the other docker containers can communicate with it. My problem is that upon reboot of docker the containers all change dynamic IPs within the subnet which causes outages because of lack of connection to that necessary single container.
Upon start it says “Creating network “docker_default” with the default driver”.
I tried the below with the goal of it all being on one single subnet. I tried specifying an IP just for the necessary container and for all, none worked.
I am a NEWBIE here so please recognize my ignorance at the outset of any reply. Thanks in advance.
version: “3.6”
networks: app_subnet: driver: bridge ipam: config: - subnet: 172.16.1.0/24 gateway: 172.16.1.1
services:
portainer:
image: portainer/portainer
hostname: portainer
container_name: portainer
restart: always
command: -H unix:///var/run/docker.sock
ports:
- “9000:9000”
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${USERDIR}/docker/portainer/data:/data
- ${USERDIR}/docker/shared:/shared
environment:
- TZ=${TZ}homeassistant:
container_name: homeassistant
hostname: hass
restart: always
image: homeassistant/home-assistantdevices:
- /dev/ttyUSB0:/dev/ttyUSB0
- /dev/ttyUSB1:/dev/ttyUSB1
- /dev/ttyACM0:/dev/ttyACM0
volumes: - ${USERDIR}/docker/homeassistant:/config - /etc/localtime:/etc/localtime:ro - ${USERDIR}/docker/shared:/shared ports: - "8123:8123" networks: app_subnet: ipv4_address: 172.16.1.3 privileged: true environment: - PUID=${PUID} - PGID=${PGID} - TZ=${TZ}
nextcloud:
container_name: nextcloud
hostname: nextcloud
restart: always
image: linuxserver/nextcloud
volumes:
- ${USERDIR}/docker/nextcloud:/config
- ${USERDIR}/shared_data:/data
- ${USERDIR}/docker/shared:/shared
ports:
- “443:443”
networks:
app_subnet:
ipv4_address: 172.16.1.4
environment:
- PUID=${PUID}
- PGID=${PGID}…