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: #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 92fad86
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion images/fedora/f32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
### Enter the toolbox:
```console
[user@hostname ~]$ toolbox enter
⬢[user@toolbox ~]$
⬢[user@fedora-toolbox-<version-id> ~]$
```

### Remove a toolbox container:
Expand Down
2 changes: 1 addition & 1 deletion images/fedora/f33/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
### Enter the toolbox:
```console
[user@hostname ~]$ toolbox enter
⬢[user@toolbox ~]$
⬢[user@fedora-toolbox-<version-id> ~]$
```

### Remove a toolbox container:
Expand Down
2 changes: 1 addition & 1 deletion images/fedora/f34/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
### Enter the toolbox:
```console
[user@hostname ~]$ toolbox enter
⬢[user@toolbox ~]$
⬢[user@fedora-toolbox-<version-id> ~]$
```

### Remove a toolbox container:
Expand Down
2 changes: 1 addition & 1 deletion images/fedora/f35/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
### Enter the toolbox:
```console
[user@hostname ~]$ toolbox enter
⬢[user@toolbox ~]$
⬢[user@fedora-toolbox-<version-id> ~]$
```

### Remove a toolbox container:
Expand Down
2 changes: 1 addition & 1 deletion images/fedora/f36/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
### Enter the toolbox:
```console
[user@hostname ~]$ toolbox enter
⬢[user@toolbox ~]$
⬢[user@fedora-toolbox-<version-id> ~]$
```

### Remove a toolbox container:
Expand Down
2 changes: 1 addition & 1 deletion images/fedora/f37/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
### Enter the toolbox:
```console
[user@hostname ~]$ toolbox enter
⬢[user@toolbox ~]$
⬢[user@fedora-toolbox-<version-id> ~]$
```

### Remove a toolbox container:
Expand Down
7 changes: 5 additions & 2 deletions src/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,12 @@ 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",
"--add-host", containerHostname + ":127.0.0.1",
"--hostname", containerHostname,
"--ipc", "host",
"--label", "com.github.containers.toolbox=true",
}...)
Expand All @@ -429,7 +433,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 92fad86

Please sign in to comment.