Docker Community Forums

Share and learn in the Docker community.

/etc/machine-id

Hi,
Can Anyone explain this phenomenon to me? It is MacOS Catalina and Docker 19.03.12.

$ cat /etc/machine-id
cat: /etc/machine-id: No such file or directory

$ docker run -it --rm -v /etc/machine-id:/etc/machine-id alpine:3.12 cat /etc/machine-id
1fddf9e8-e650-4884-a953-0ce9efdf922d

$ docker run -it --rm alpine:3.12 cat /etc/machine-id
cat: can't open '/etc/machine-id': No such file or directory

And when I try to map other non-existing file from /etc/

$ cat /etc/machine
cat: /etc/machine: No such file or directory

$ docker run -it --rm -v /etc/machine:/etc/machine alpine:3.12 cat /etc/machine-id
docker: Error response from daemon: Mounts denied:
The path /etc/machine
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing.
See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
.
ERRO[0000] error waiting for container: context canceled

Which is expected

So one more test:

# echo "test" > /etc/machine-id
# cat /etc/machine-id
test
# docker run -it --rm -v /etc/machine:/etc/machine alpine:3.12 cat /etc/machine-id
docker: Error response from daemon: Mounts denied:
The path /etc/machine
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing. 
See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
.
ERRO[0000] error waiting for container: context canceled

Which is expected!

So my questions are:

  1. Which /etc/machine-id file is used.
  2. Why volume binding works specifically for that file if it does not exists on the host machine?
  3. Does it work the same on other host OS’es?