Skip to content

Commit 1b4d28c

Browse files
committed
fix: don't use toolbox as constant for FQDN
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. Signed-off-by: Alex Diaz <[email protected]>
1 parent afb002c commit 1b4d28c

File tree

8 files changed

+11
-16
lines changed

8 files changed

+11
-16
lines changed

images/fedora/f32/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
5454
### Enter the toolbox:
5555
```console
5656
[user@hostname ~]$ toolbox enter
57-
⬢[user@toolbox ~]$
57+
⬢[user@fedora-toolbox-<version-id> ~]$
5858
```
5959

6060
### Remove a toolbox container:

images/fedora/f33/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
5757
### Enter the toolbox:
5858
```console
5959
[user@hostname ~]$ toolbox enter
60-
⬢[user@toolbox ~]$
60+
⬢[user@fedora-toolbox-<version-id> ~]$
6161
```
6262

6363
### Remove a toolbox container:

images/fedora/f34/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
5757
### Enter the toolbox:
5858
```console
5959
[user@hostname ~]$ toolbox enter
60-
⬢[user@toolbox ~]$
60+
⬢[user@fedora-toolbox-<version-id> ~]$
6161
```
6262

6363
### Remove a toolbox container:

images/fedora/f35/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
5757
### Enter the toolbox:
5858
```console
5959
[user@hostname ~]$ toolbox enter
60-
⬢[user@toolbox ~]$
60+
⬢[user@fedora-toolbox-<version-id> ~]$
6161
```
6262

6363
### Remove a toolbox container:

images/fedora/f36/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
5757
### Enter the toolbox:
5858
```console
5959
[user@hostname ~]$ toolbox enter
60-
⬢[user@toolbox ~]$
60+
⬢[user@fedora-toolbox-<version-id> ~]$
6161
```
6262

6363
### Remove a toolbox container:

images/fedora/f37/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This will create a container called `fedora-toolbox-<version-id>`.
5757
### Enter the toolbox:
5858
```console
5959
[user@hostname ~]$ toolbox enter
60-
⬢[user@toolbox ~]$
60+
⬢[user@fedora-toolbox-<version-id> ~]$
6161
```
6262

6363
### Remove a toolbox container:

src/cmd/create.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,12 @@ func createContainer(container, image, release string, showCommandToEnter bool)
418418

419419
createArgs = append(createArgs, xdgRuntimeDirEnv...)
420420

421+
hostname, err := os.Hostname()
422+
containerHostname := container + "." + hostname
423+
421424
createArgs = append(createArgs, []string{
422-
"--hostname", "toolbox",
425+
"--add-host", containerHostname + ":127.0.0.1",
426+
"--hostname", containerHostname,
423427
"--ipc", "host",
424428
"--label", "com.github.containers.toolbox=true",
425429
}...)
@@ -429,7 +433,6 @@ func createContainer(container, image, release string, showCommandToEnter bool)
429433
createArgs = append(createArgs, []string{
430434
"--name", container,
431435
"--network", "host",
432-
"--no-hosts",
433436
"--pid", "host",
434437
"--privileged",
435438
"--security-opt", "label=disable",

src/cmd/initContainer.go

-8
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,6 @@ func initContainer(cmd *cobra.Command, args []string) error {
177177
}
178178
}
179179

180-
if _, err := os.Readlink("/etc/hosts"); err != nil {
181-
if err := redirectPath("/etc/hosts",
182-
"/run/host/etc/hosts",
183-
false); err != nil {
184-
return err
185-
}
186-
}
187-
188180
if localtimeTarget, err := os.Readlink("/etc/localtime"); err != nil ||
189181
localtimeTarget != "/run/host/etc/localtime" {
190182
if err := redirectPath("/etc/localtime",

0 commit comments

Comments
 (0)