Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing both --uts=host and --network=host results in unexpected /etc/hostname #20448

Closed
dtantsur opened this issue Oct 23, 2023 · 1 comment · Fixed by #20545
Closed

Providing both --uts=host and --network=host results in unexpected /etc/hostname #20448

dtantsur opened this issue Oct 23, 2023 · 1 comment · Fixed by #20545
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@dtantsur
Copy link

Issue Description

Normally, enabling host networking makes /etc/hostname match the real hostname of the machine where the container is running. However, adding --uts=host on top of that, resets /etc/hostname to the generated one. Illustrated:

~/P/podman (main) $ bin/podman run --rm -it centos:stream9
[root@85ab9d9e5f41 /]# uname -n
85ab9d9e5f41
[root@85ab9d9e5f41 /]# cat /etc/hostname 
85ab9d9e5f41[root@85ab9d9e5f41 /]# 
exit

~/P/podman (main) $ bin/podman run --rm -it --network=host centos:stream9
[root@dtantsur-laptop /]# uname -n
dtantsur-laptop
[root@dtantsur-laptop /]# cat /etc/hostname 
dtantsur-laptop[root@dtantsur-laptop /]# 
[root@dtantsur-laptop /]# 
exit

~/P/podman (main) $ bin/podman run --rm -it --network=host --uts=host centos:stream9
[root@dtantsur-laptop /]# uname -n
dtantsur-laptop
[root@dtantsur-laptop /]# cat /etc/hostname 
2bc6e6a91156[root@dtantsur-laptop /]# 
[root@dtantsur-laptop /]# 
exit

Steps to reproduce the issue

Steps to reproduce the issue

  1. See commands in the past above

Describe the results you received

/etc/hostname contains an autogenerated host name despite both --uts=host and --network=host.

Describe the results you expected

/etc/hostname matches the output of uname -n

podman info output

host:
  arch: amd64
  buildahVersion: 1.33.0-dev
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.7-2.fc38.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.7, commit: '
  cpuUtilization:
    idlePercent: 44.44
    systemPercent: 11.2
    userPercent: 44.36
  cpus: 8
  databaseBackend: boltdb
  distribution:
    distribution: fedora
    variant: matecompiz
    version: "38"
  eventLogger: journald
  freeLocks: 2048
  hostname: dtantsur-laptop
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.5.6-200.fc38.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 898678784
  memTotal: 16516935680
  networkBackend: cni
  networkBackendInfo:
    backend: cni
    dns: {}
    package: containernetworking-plugins-1.3.0-2.fc38.x86_64
    path: /usr/libexec/cni
  ociRuntime:
    name: crun
    package: crun-1.9.2-1.fc38.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.9.2
      commit: 35274d346d2e9ffeacb22cc11590b0266a23d634
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20231004.gf851084-1.fc38.x86_64
    version: |
      pasta 0^20231004.gf851084-1.fc38.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: false
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.1-1.fc38.x86_64
    version: |-
      slirp4netns version 1.2.1
      commit: 09e31e92fa3d2a1d3ca261adaeb012c8d75a8194
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 6367764480
  swapTotal: 8589930496
  uptime: 169h 35m 43.00s (Approximately 7.04 days)
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/dtantsur/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: fuse-overlayfs-1.12-1.fc38.x86_64
      Version: |-
        fusermount3 version: 3.14.1
        fuse-overlayfs: version 1.12
        FUSE library version 3.14.1
        using FUSE kernel interface version 7.31
  graphRoot: /home/dtantsur/.local/share/containers/storage
  graphRootAllocated: 438636322816
  graphRootUsed: 349286375424
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "true"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 186
  runRoot: /run/user/1000
  transientStore: false
  volumePath: /home/dtantsur/.local/share/containers/storage/volumes
version:
  APIVersion: 4.8.0-dev
  Built: 1698055488
  BuiltTime: Mon Oct 23 12:04:48 2023
  GitCommit: 19c870da0d4923b2bf2d62b5d424da5a649b4d40
  GoVersion: go1.21.1
  Os: linux
  OsArch: linux/amd64
  Version: 4.8.0-dev

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

Tested on my Fedora laptop based on feedback from CoreOS 8 users.

Additional information

No response

@dtantsur dtantsur added the kind/bug Categorizes issue or PR as related to a bug. label Oct 23, 2023
@cgiradkar cgiradkar self-assigned this Oct 23, 2023
@giuseppe
Copy link
Member

opened a PR: #20545

giuseppe added a commit to giuseppe/libpod that referenced this issue Oct 31, 2023
when --uts=host is provided, the expectation is to use the hostname
from the host not the container name.

Closes: containers#20448

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Jan 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants