Docker run command by default uses a dedicated UTS namespace for the container and because of it the container gets its own/unique hostname. I am trying to share the UTS namespace between two containers but it seems that it is not possible with docker run command.
Following are the commands that I ran -
docker run -d --name container1 alpine sleep infinity
docker run -it --name container2 --uts container:container1 alpine /bin/sh
Error -
docker: --uts: invalid UTS mode.
Based on the documentation, it looks like it is not possible to reference a container with the --uts flag. This is not the case with other namespace related flags like --pid, --network, etc. They support referencing other containers. Why "container:<name|id>” mode is not supported by the --utc flag? How to share UTS namespace between containers so that they share hostname?