cmd:
docker run -d --hostname rabbit1 --name rabbit1 -v /etc/localtime:/etc/localtime:ro -p 15672:15672 -p 5672:5672 -e RABBITMQ_ERLANG_COOKIE='rabbitcookie' rabbitmq:latest
stdout:
docker: Error response from daemon: error while creating mount source path '/etc/localtime': mkdir /etc/localtime: file exists.
how to resolved?
Not sure why you're encountering that error, are you using Docker for Mac/Win?
$ docker run --rm -d --hostname rabbit1 --name rabbit1 -v /etc/localtime:/etc/localtime:ro -p 15672:15672 -p 5672:5672 -e RABBITMQ_ERLANG_COOKIE='rabbitcookie' rabbitmq:latest
67e8c404a1e1608a7e49ca92bc9a90686f821d8184ca9bdc1f34994da71db251
$ docker exec -it rabbit1 bash
root@rabbit1:/# date
Wed Feb 13 08:52:12 PST 2019
root@rabbit1:/# exit
exit
$ date
Wed Feb 13 08:52:20 PST 2019
$ docker inspect rabbit1
. . .
"Mounts": [
{
"Type": "bind",
"Source": "/etc/localtime",
"Destination": "/etc/localtime",
"Mode": "ro",
"RW": false,
"Propagation": "rprivate"
},
. . .
@wglambert Using Version: Docker for Mac 18.09.1
There's an issue on Docker for Mac, also some workarounds in that thread https://github.com/docker/for-mac/issues/2396#issuecomment-358118186
it is actually trying to mkdir the directory on the MacOS side. As an aside this works perfectly in Ubuntu 16.04 with the latest docker, so it looks like a regression
Going to close since is a Docker for Mac issue