Skip to content

Setting UTS mode causes container to not be re-creatable #176

@Nunction

Description

@Nunction

Describe the bug

Configuring a container to use uts results in watchtower to fail to recreate that container during update as it attempts to set both the hostname and uts mode which results in a conflict response from the daemon.

Steps to reproduce

  1. Create a service that sets uts mode to e.g. host
  2. Let watchtower run
  3. See error
services:
  watchtower:
    image: beatkind/watchtower:latest
    volumes:
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
        read_only: true

  example:
    image: debian:stable
    uts: host

Expected behavior

If uts is set the hostname (and probably also domain name) value is ignored during recreation and only the uts option is passed to the daemon.

Screenshots

No response

Environment

Client: Docker Engine - Community
 Version:    29.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.30.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.40.3
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 3
  Running: 3
  Paused: 0
  Stopped: 0
 Images: 9
 Server Version: 29.0.2
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: journald
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: fcd43222d6b07379a4be9786bda52438f0dd16a1
 runc version: v1.3.3-0-gd842d771
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.8.0-88-generic
 Operating System: Ubuntu 24.04.3 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.755GiB
 Name: glr1
 ID: 9dca9b22-6fe5-4e0e-8cb9-7be6e69d6955
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false
 Default Address Pools:
   Base: 10.208.0.0/16, Size: 24
 Firewall Backend: iptables

Reproducible on multiple different systems.

Your logs

level=error msg="Error response from daemon: conflicting options: hostname and the UTS mode"

Additional context

A docker inspect for a running container shows that the "configured" hostname for that container matches the hostname of the host (as expected for uts: host) however this should only be a runtime value which is derived from the host due to the uts mode. My uneducated guess is that watchtower sees this configured hostname and attempts to copy it to the newly created container.

{
        "HostConfig": {
            "UTSMode": "host",
        },
        "Config": {
            "Hostname": "glr1",
            "Domainname": ""
        }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions