abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
18.63k stars 380 forks source link

Suuport adding extra IP addresses #1118

Open dmarkey opened 3 weeks ago

dmarkey commented 3 weeks ago

Description

Hey, thanks for colima!

We have a private IP that we use for local development thats not 127.0.0.1. So I we have to fiddle with adding IP aliases on loopback like this on the host:

    if [ $(uname) == "Darwin" ] ; then
        sudo ifconfig lo0 alias 172.16.1.1  255.255.255.255
        sudo ifconfig lo0  alias 172.16.1.200  255.255.255.255
    fi

    if [ $(uname) == "Linux" ] ; then
        if ! ip addr show to 172.16.1.1 | grep UP ; then
            sudo ip addr add 172.16.1.1/24 dev lo
            sudo ip addr add 172.16.1.200/24 dev lo
        fi
    fi
}

Would be great if this could be built in.

abiosoft commented 3 weeks ago

If you're on version v0.7.3, you can start Colima with --network-host-addresses and you'd be able to use those addresses for port forwarding.

docker run --rm -it -p 172.16.1.200:80:80 caddy