Skip to main content

Mismatch Between Docker and Machine Hostnames

There is a limitation in Docker runtime which prevents running containers from being notified when Docker updates the hostname.

To correct this mismatch:

  1. Find the current Docker hostname.

    hostname
    Example output
    coreos-1122.3.0
  2. Update the hostname in the Docker host.

    sudo hostname new-coreos-1122.3.0
  3. Find the Linux process id of the Lacework datacollector container.

    sudo docker ps -a
    Example output
    0123ae6c9bd9 lacework/datacollector:latest “/var/lib/backup/data” 2 hours ago Up 2 hours datacollector
  4. Find the PID of the Lacework datacollector container.

    sudo docker inspect 0123ae6c9bd9 | grep Pid
    Example output
    “Pid”: 2897,
    “PidMode”: “host”,
    “PidsLimit”: 0,
  5. Edit the UTS namespace of the Lacework datacollector container and update it with the new hostname, where nsenter is part of the util-linux package.

    sudo nsenter --target 2897 --uts hostname new-coreos-1122.3.0
  6. Log in to the Lacework agent container and verify that the new hostname is visible.

    sudo docker exec -it 0123ae6c9bd9 /bin/bash   
    root@new-coreos-1122:/# hostname  
    new-coreos-1122.3.0 12

You should not have to restart the Lacework agent container to display the new hostname.