Skip to content

Commit

Permalink
fix: don't use toolbox as constant for FQDN
Browse files Browse the repository at this point in the history
issue: containers#969

Setting the hostname to toolbox causes timeouts whenever anything tries
to resolve the name of the machine - for example `sudo` does this.

This change makes it so the FQDN is set to
`${container_name}.${hostname}` as recommended in the linked issue.

After this change commands can properly resolve the local FQDN.
  • Loading branch information
akdev1l committed Aug 17, 2022
1 parent afb002c commit 2c136dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,11 @@ func createContainer(container, image, release string, showCommandToEnter bool)

createArgs = append(createArgs, xdgRuntimeDirEnv...)

hostname, err := os.Hostname()
containerHostname := container + "." + hostname

createArgs = append(createArgs, []string{
"--hostname", "toolbox",
"--hostname", containerHostname,
"--ipc", "host",
"--label", "com.github.containers.toolbox=true",
}...)
Expand All @@ -429,7 +432,6 @@ func createContainer(container, image, release string, showCommandToEnter bool)
createArgs = append(createArgs, []string{
"--name", container,
"--network", "host",
"--no-hosts",
"--pid", "host",
"--privileged",
"--security-opt", "label=disable",
Expand Down
8 changes: 0 additions & 8 deletions src/cmd/initContainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,6 @@ func initContainer(cmd *cobra.Command, args []string) error {
}
}

if _, err := os.Readlink("/etc/hosts"); err != nil {
if err := redirectPath("/etc/hosts",
"/run/host/etc/hosts",
false); err != nil {
return err
}
}

if localtimeTarget, err := os.Readlink("/etc/localtime"); err != nil ||
localtimeTarget != "/run/host/etc/localtime" {
if err := redirectPath("/etc/localtime",
Expand Down

0 comments on commit 2c136dc

Please sign in to comment.