Assigning separate ip's for each container

At first, I needed to assign a separate IP address for portainer login Ui. So I followed this guide Using macvlan portainer.

  1. Created a mymacvlan config.
    Name|mymacvlanconfig
    Driver null
    Scope local
    Attachable false
    Internal false
    |IPV4 Subnet - 192.168.88.0/24
    IPV4 Gateway - 192.168.88.1
    |IPV4 IP range - 192.168.88.7/32
    (192.168.88.7- This is where I wanted to login my portainer UI)

  2. Created another network using the mymacvlan config.
    mymacvlan
    Driver macvlan
    Scope local
    Attachable true
    Internal false
    IPV4 Subnet - 192.168.88.0/24
    IPV4 Gateway - 192.168.88.1
    IPV4 IP range - 192.168.88.7/32

I have also a Pihole docker container running and needed its IP also to be changed. So, again

  1. Created a piholemacvlan config
    Driver null
    Scope local
    Attachable false
    Internal false
    IPV4 Subnet - 192.168.88.0/24
    IPV4 Gateway - 192.168.88.1
    IPV4 IP range - 192.168.88.5/32
    (192.168.88.5- This is where I wanted to login pihole Ui)

4.Created a network using the piholemacvlan config.
piholemacvlan
Driver macvlan
Scope local
Attachable true
Internal false
IPV4 Subnet - 192.168.88.0/24
IPV4 Gateway - 192.168.88.1
IPV4 IP range - 192.168.88.5/32
Problem arises when I click the 'Create Network".Its throws error:failure failed to allocate gateway address already in use

Through searching found out that a gateway can be only used only one macvlan network and this gateway is a virtual gateway, not the actually plan gateway. So, do I need to change the gateway on piholemacvlan config file to 192.168.88.2 or any other unused Ip address?

I am actually trying to assign individual Ip to each container. Can it be done by a single config file, which will assign each container a static Ip address?

@sohojmanush You’re trying to use the same ip range for all of your vlans that is impossible (the way you are trying to do it) not only from a Docker side of things but from a portainer side of things as well.

Your first configuration is fine except, why are you trying to minimize it to 1 ip? You should either use a DHCP scope for the containers to use, you can do that with macvlan or you can assign a static ip to the container itself.

Your macvlan should be configure like the following:
Macvlan to Segment Networks

You will need to segment your network /24 in the manner they are showing you in the docker link I presented you.

I hope this helps you understand.
Michael