Using docker on OpenWrt, how to change container's IP address?

I want to move the unifi controller from the cloudkey into a container on OpenWrt.

I'm using this docker-compose file:

xg-135r3 in /etc/docker/unifi-controller # cat docker-compose.yml
---
version: "2.1"
services:
  unifi-controller:
    image: lscr.io/linuxserver/unifi-controller:latest
    container_name: unifi-controller
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Vancouver
      - MEM_LIMIT=1024 #optional
      - MEM_STARTUP=1024 #optional
    volumes:
      - /etc/unifi-controller:/config
    ports:
      - 8443:8443
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
      - 1900:1900/udp #optional
      - 8843:8843 #optional
      - 8880:8880 #optional
      - 6789:6789 #optional
      - 5514:5514/udp #optional
    restart: unless-stopped

What's the best way to assign an IP address to the container different from my router's IP? Instead of 192.168.1.1 I want it to be 192.168.1.10 (same as the unplugged cloudkey) so I could just import the config and not adopt all the devices again?

I don’t know if this is the most elegant way but this should work:

I assume 192.168.1.1 is you LAN ip.

Go and add another static ip to your LAN interface = 192.168.1.10

Then bind all the ports of your container to 192.168.1.10

Should look like this:

    ports:
      - 192.168.1.10:8443:8443
      - 192.168.1.10:3478:3478/udp
      - 192.168.1.10:10001:10001/udp
      - 192.168.1.10:8080:8080
      - 192.168.1.10:1900:1900/udp #optional
      - 192.168.1.10:8843:8843 #optional
      - 192.168.1.10:8880:8880 #optional
      - 192.168.1.10:6789:6789 #optional
      - 192.168.1.10:5514:5514/udp #optional
2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.