Skip to content

Commit

Permalink
install bind-tools in Alpine base to prevent DNS failure
Browse files Browse the repository at this point in the history
  • Loading branch information
slimsag committed Oct 29, 2018
1 parent 0f33644 commit 5cf4e6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions godockerize.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ func doBuild(c *cli.Context) error {
echo -e "http://dl-cdn.alpinelinux.org/alpine/%s/community\n" >> /etc/apk/repositories
`, repos[i], repos[i])
}
if strings.HasPrefix(c.String("base"), "alpine") {
// IMPORTANT: Alpine by default does not come with some packages that
// are needed for working DNS to other containers on a user-defined
// Docker network. Without installing this package, nslookup and Go etc
// will fail to contact other Docker containers.
// See https://github.com/sourcegraph/deploy-sourcegraph-docker/issues/1
install = append(install, "bind-tools")
}
if len(install) != 0 {
fmt.Fprintf(&dockerfile, " RUN apk add --no-cache %s\n", strings.Join(sortedStringSet(install), " "))
}
Expand Down

1 comment on commit 5cf4e6d

@slimsag
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context: First encountered in sourcegraph/deploy-sourcegraph-docker#1

Without this flag, on Docker for Mac the DNS lookup of other containers fails.

On at least some Docker for Mac versions and some Linux hosts:

Apparently, installing bind-tools fixes the issue. I noticed this because after installing the dig tool, DNS lookup suddenly started passing:

/ # nslookup sourcegraph-frontend-internal
nslookup: can't resolve '(null)': Name does not resolve

Name:      sourcegraph-frontend-internal
Address 1: 172.29.0.16 sourcegraph-frontend-internal.sourcegraph
/ # dig sourcegraph-frontend-internal
sh: dig: not found
/ # apk add --no-cache bind-tools
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/5) Installing libgcc (6.4.0-r9)
(2/5) Installing json-c (0.13.1-r0)
(3/5) Installing libxml2 (2.9.8-r1)
(4/5) Installing bind-libs (9.12.2_p1-r0)
(5/5) Installing bind-tools (9.12.2_p1-r0)
Executing busybox-1.28.4-r1.trigger
OK: 11 MiB in 25 packages
/ # nslookup sourcegraph-frontend-internal
Server:		127.0.0.11
Address:	127.0.0.11#53

Non-authoritative answer:
Name:	sourcegraph-frontend-internal
Address: 172.29.0.16

After discovering this, it became apparent I am not the only one to run into this: nodejs/docker-node#339

I will update our images to all install bind-tools.

Please sign in to comment.