Skip to content

Commit 61ab8c7

Browse files
authored
network: fixes for docker/containerd (#201)
* core: update iso to 0.3.4 * docker: support host.docker.internal hostname * fix #186: 3-part port binding is not respected
1 parent ac876a5 commit 61ab8c7

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

environment/vm/lima/yaml.go

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func newConf(conf config.Config) (l Config, err error) {
1717
l.Arch = environment.Arch(conf.VM.Arch).Value()
1818

1919
l.Images = append(l.Images,
20-
File{Arch: environment.AARCH64, Location: "https://github.com/abiosoft/alpine-lima/releases/download/colima-v0.3.3-1/alpine-lima-clm-3.14.3-aarch64.iso", Digest: "sha512:07d5b98f93c48e103cc0a3610a99980c17a5c8ca3ea81ca66ee53de2a182d41568e6701c146728270ecf2b8a944abc34f25ebb0edcea3378f2c17c75a287f85c"},
21-
File{Arch: environment.X8664, Location: "https://github.com/abiosoft/alpine-lima/releases/download/colima-v0.3.3-1/alpine-lima-clm-3.14.3-x86_64.iso", Digest: "sha512:1bcdf1fec1f7de5938a1dd6effad9546d20ff6caf6eefc8224a66af74891f0337f6f1e9bb8c2b3231e1364be004c3b25457cbc427968e27750d60662093538aa"},
20+
File{Arch: environment.AARCH64, Location: "https://github.com/abiosoft/alpine-lima/releases/download/colima-v0.3.4/alpine-lima-clm-3.14.3-aarch64.iso", Digest: "sha512:9a964a8709e6813cfdfc4ac58a5c811de04aa6eb1a41c13fe9662b39a28af8222d2684e501637d6e294f3857328a46d69969c3e6b8868eb633478596733f168e"},
21+
File{Arch: environment.X8664, Location: "https://github.com/abiosoft/alpine-lima/releases/download/colima-v0.3.4/alpine-lima-clm-3.14.3-x86_64.iso", Digest: "sha512:20237c13bf6e4769d4b027934d7084d436f3b930f4d8289aaba85d1db3025d28f0eabf7ea4aba8adef48ce3de1de3616a72b2fa8b31e818a6d30f4904483b8d9"},
2222
)
2323

2424
l.CPUs = conf.VM.CPU
@@ -33,6 +33,9 @@ func newConf(conf config.Config) (l Config, err error) {
3333
// always use host resolver to generate Lima's default resolv.conf file
3434
// colima will override this in VM when custom DNS is set
3535
l.HostResolver.Enabled = true
36+
l.HostResolver.Hosts = map[string]string{
37+
"host.docker.internal": "host.lima.internal",
38+
}
3639

3740
l.Env = map[string]string{}
3841
for k, v := range conf.VM.Env {
@@ -52,11 +55,23 @@ func newConf(conf config.Config) (l Config, err error) {
5255
}
5356

5457
// handle port forwarding to allow listening on 0.0.0.0
58+
// bind 0.0.0.0
59+
l.PortForwards = append(l.PortForwards,
60+
PortForward{
61+
GuestIPMustBeZero: true,
62+
GuestIP: net.ParseIP("0.0.0.0"),
63+
GuestPortRange: [2]int{1, 65535},
64+
HostIP: net.ParseIP("0.0.0.0"),
65+
HostPortRange: [2]int{1, 65535},
66+
Proto: TCP,
67+
},
68+
)
69+
// bind 127.0.0.1
5570
l.PortForwards = append(l.PortForwards,
5671
PortForward{
5772
GuestIP: net.ParseIP("127.0.0.1"),
5873
GuestPortRange: [2]int{1, 65535},
59-
HostIP: conf.PortInterface,
74+
HostIP: net.ParseIP("127.0.0.1"),
6075
HostPortRange: [2]int{1, 65535},
6176
Proto: TCP,
6277
},
@@ -152,21 +167,23 @@ const (
152167
)
153168

154169
type PortForward struct {
155-
GuestIP net.IP `yaml:"guestIP,omitempty" json:"guestIP,omitempty"`
156-
GuestPort int `yaml:"guestPort,omitempty" json:"guestPort,omitempty"`
157-
GuestPortRange [2]int `yaml:"guestPortRange,omitempty" json:"guestPortRange,omitempty"`
158-
GuestSocket string `yaml:"guestSocket,omitempty" json:"guestSocket,omitempty"`
159-
HostIP net.IP `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
160-
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
161-
HostPortRange [2]int `yaml:"hostPortRange,omitempty" json:"hostPortRange,omitempty"`
162-
HostSocket string `yaml:"hostSocket,omitempty" json:"hostSocket,omitempty"`
163-
Proto Proto `yaml:"proto,omitempty" json:"proto,omitempty"`
164-
Ignore bool `yaml:"ignore,omitempty" json:"ignore,omitempty"`
170+
GuestIPMustBeZero bool `yaml:"guestIPMustBeZero,omitempty" json:"guestIPMustBeZero,omitempty"`
171+
GuestIP net.IP `yaml:"guestIP,omitempty" json:"guestIP,omitempty"`
172+
GuestPort int `yaml:"guestPort,omitempty" json:"guestPort,omitempty"`
173+
GuestPortRange [2]int `yaml:"guestPortRange,omitempty" json:"guestPortRange,omitempty"`
174+
GuestSocket string `yaml:"guestSocket,omitempty" json:"guestSocket,omitempty"`
175+
HostIP net.IP `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
176+
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
177+
HostPortRange [2]int `yaml:"hostPortRange,omitempty" json:"hostPortRange,omitempty"`
178+
HostSocket string `yaml:"hostSocket,omitempty" json:"hostSocket,omitempty"`
179+
Proto Proto `yaml:"proto,omitempty" json:"proto,omitempty"`
180+
Ignore bool `yaml:"ignore,omitempty" json:"ignore,omitempty"`
165181
}
166182

167183
type HostResolver struct {
168-
Enabled bool `yaml:"enabled" json:"enabled"`
169-
IPv6 bool `yaml:"ipv6,omitempty" json:"ipv6,omitempty"`
184+
Enabled bool `yaml:"enabled" json:"enabled"`
185+
IPv6 bool `yaml:"ipv6,omitempty" json:"ipv6,omitempty"`
186+
Hosts map[string]string `yaml:"hosts,omitempty" json:"hosts,omitempty"`
170187
}
171188

172189
type volumeMount string

0 commit comments

Comments
 (0)