for-mac icon indicating copy to clipboard operation
for-mac copied to clipboard

After Docker upgrade - results in "The path /etc/localtime is not shared from OS X and is not known to Docker"

Open shusak opened this issue 8 years ago • 76 comments

Expected behavior

Docker upgrade shouldn't affect already working mount mappings.

Actual behavior

Upgrade to new version of docker on Mac OSX now results in "The path /etc/localtime is not shared from OS X and is not known to Docker".

Information

  • Full output of the diagnostics from "Diagnose & Feedback" in the menu

Docker for Mac: version: 17.12.0-ce-mac46 (a61e84b8bca06b1ae6ce058cdd7beab1520ad622) macOS: version 10.12.6 (build: 16G1114) logs: /tmp/072847D3-A6CD-4D63-BC1A-BE8199F81553/20180110-104443.tar.gz [OK] db.git [OK] vmnetd [OK] dns [OK] driver.amd64-linux [OK] virtualization VT-X [OK] app [OK] moby [OK] system [OK] moby-syslog [OK] kubernetes [OK] env [OK] virtualization kern.hv_support [OK] slirp [OK] osxfs [OK] moby-console [OK] logs [OK] docker-cli [OK] menubar [OK] disk

  • A reproducible case if this is a bug, Dockerfiles FTW
  • Page URL if this is a docs issue or the name of a man page

Steps to reproduce the behavior

1.On previous version, Existing docker run command executed successfully as:

docker run -d -p 80 \
    --name ${CONTAINER_NAME} \
    --restart=always \
    -v /etc/localtime:/etc/localtime:ro \
    -v ${ENV_APPDIR}/app:/usr/share/app:ro \
    -l agent-host=${agent_host} \
    ${CONTAINER_NAME}
  1. Upgrade to new Docker release
  2. Same docker run command now fails with
docker: Error response from daemon: Mounts denied:
The path /etc/localtime
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.

shusak avatar Jan 10 '18 15:01 shusak

Having the same problem

gpirescampos avatar Jan 11 '18 16:01 gpirescampos

I am also having same problem

drupler avatar Jan 12 '18 12:01 drupler

Same on me

konstantinzolotarev avatar Jan 12 '18 12:01 konstantinzolotarev

Facing same issue. Downgraded docker to Version 17.09.1-ce-mac42 to proceed for now.

kumvem avatar Jan 12 '18 16:01 kumvem

Same on me

netcookies avatar Jan 14 '18 04:01 netcookies

I also have the same issue. Downgrading if i can figure out how

Casper-O avatar Jan 14 '18 12:01 Casper-O

If you go to Preferences/File Sharing, is /etc in the list, and does adding it again fix the issue?

justincormack avatar Jan 14 '18 14:01 justincormack

@justincormack No /etc is not in the list and it's not possible to add it there with message:

The path /etc is reserved by Docker however it may be possible to export specific subdirectories.

konstantinzolotarev avatar Jan 14 '18 18:01 konstantinzolotarev

Having the same issue,

purinda avatar Jan 14 '18 23:01 purinda

Ah ok, it looks like the host does not have an /etc/localtime file. If it did, it would only have UTC in, you are probably better off adding that to your container or omitting it.

What exactly are you trying to achieve by bind mounting it? Which local time are you interested in?

justincormack avatar Jan 15 '18 11:01 justincormack

On my machine:

$ ls -la /etc/localtime
lrwxr-xr-x  1 root  wheel  36 Aug 24 13:17 /etc/localtime -> /usr/share/zoneinfo/America/New_York

I think this technique is a popular solution to configure a container's timezone.

shusak avatar Jan 16 '18 18:01 shusak

I have this same issue, with

  • Version 17.12.0-ce-mac47 (21805)
  • Version 17.12.0-ce-mac46 (didn't record build#)

Specifically on OSX, /etc is actually a symlink to /private/etc.

I know that /etc cannot be added as a shared directory. Presumably, because it'll be overlaid on the Moby VM at /etc which will kill the actual VM that serves our Docker daemon (this was always my understanding).

By happy coincidence, though, that /private/etc symlink would be resolved by the Docker-for-Mac system and since /private is a shared directory, it would work.

Could this be a regression in docker / Docker-for-Mac's handling of symlinks in bind-mounts?

For now, I work around the issue by re-installing an older version: Docker-for-Mac 17.09.1-ce-mac42 (21090)

Gengar003 avatar Jan 16 '18 20:01 Gengar003

If you do add /etc/localtime to the Docker for Mac Preferences/File Sharing, then you get a different error which seems to show that on Version 17.12.0-ce-mac45 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:

docker run -it -v /etc/localtime:/etc/localtime:ro hello-world
docker: Error response from daemon: error while creating mount source path '/etc/localtime': mkdir /etc/localtime: file exists.

richtong avatar Jan 16 '18 21:01 richtong

Same issue: here's my OSX-specific workaround.

  • Make sure you have the tzdata package installed in the container
  • Add -e TZ=`ls -la /etc/localtime | cut -d/ -f8-9` to the docker run command line

gi-el avatar Jan 17 '18 00:01 gi-el

Ah nice trick. Smart to use an env variable instead. Hopefully they

Thanks, Rich

Sent from my iPhone X http://tongfamily.com | @richtong | https://fb.me/richtong1

On Jan 16, 2018, at 16:12, Giel [email protected] wrote:

Same issue: here's my OSX-specific workaround.

Make sure you have the tzdata package installed in the container Add -e TZ=ls -la /etc/localtime | cut -d/ -f8-9 to the docker run command line — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

richtong avatar Jan 17 '18 14:01 richtong

I have the same issue, and I need to make it work with docker-compose. Any suggestions?

fedorov avatar Feb 20 '18 21:02 fedorov

Solved ... specified TZ in the .env file for docker-compose. Not sure if it works, but at least I could start it up ...

fedorov avatar Feb 20 '18 21:02 fedorov

Tried setting TZ in .env file and still docker-compose fails to start.

$ echo "TZ=$(ls -la /etc/localtime | cut -d/ -f8-9)" >> .env
$ docker-compose up -d
...
Starting blockbox_cinder-volume_1 ... error

ERROR: for blockbox_cinder-volume_1  Cannot start service cinder-volume: Mounts denied:
The path /etc/localtime
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.
.

ikhere avatar Feb 24 '18 14:02 ikhere

We are also affected by this change. Please fix it.

OnkelTem avatar Feb 28 '18 15:02 OnkelTem

Any update on this bug? Will we have a fix soon?

peckhouse avatar Mar 02 '18 07:03 peckhouse