Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suuport adding extra IP addresses #1118

Open
dmarkey opened this issue Aug 22, 2024 · 2 comments
Open

Suuport adding extra IP addresses #1118

dmarkey opened this issue Aug 22, 2024 · 2 comments

Comments

@dmarkey
Copy link

dmarkey commented Aug 22, 2024

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
Copy link
Owner

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

@technicalpickles
Copy link

Is there any other steps or configuration needed? I've tried adding this to my profile:

network:
  addresses:
    - "127.0.0.1"
    - "172.16.100.1"

And I get errors like this:

❯ docker run --rm -d --name my_nginx -p 172.16.100.1:8080:80 nginx
e184eee8a693278920c00dd491bec2c7889a7a642cf10add298cd83bafb06056
docker: Error response from daemon: driver failed programming external connectivity on endpoint my_nginx (fb6a2bb42f7ebc745dfed448c6b94950e6d49b766d50b39cbe3ad0905193e1e6): failed to bind port 172.16.100.1:8080/tcp: Error starting userland proxy: listen tcp4 172.16.100.1:8080: bind: cannot assign requested address.

I have confirmed the interface is up and working in general, and used this one-liner server for ruby:

$ ruby -r webrick -e "server = WEBrick::HTTPServer.new(BindAddress: '172.16.100.1', Port: 8080, DocumentRoot: Dir.pwd); trap('INT') { server.shutdown }; server.start"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants