Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shusak opened this issue Jan 10, 2018 · 75 comments

Comments

@shusak
Copy link

shusak commented Jan 10, 2018

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 shusak changed the title Docker upgrade now results in "The path /etc/localtime is not shared from OS X and is not known to Docker" After Docker upgrade - results in "The path /etc/localtime is not shared from OS X and is not known to Docker" Jan 10, 2018
@gpirescampos
Copy link

Having the same problem

@drupler
Copy link

drupler commented Jan 12, 2018

I am also having same problem

@konstantinzolotarev
Copy link

Same on me

@kumvem
Copy link

kumvem commented Jan 12, 2018

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

@netcookies
Copy link

Same on me

@Casper-O
Copy link

Casper-O commented Jan 14, 2018

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

@justincormack
Copy link
Member

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

@konstantinzolotarev
Copy link

@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.

@purinda
Copy link

purinda commented Jan 14, 2018

Having the same issue,

@justincormack
Copy link
Member

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?

@shusak
Copy link
Author

shusak commented Jan 16, 2018

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.

@Gengar003
Copy link

Gengar003 commented Jan 16, 2018

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)

@richtong
Copy link

richtong commented Jan 16, 2018

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.

@gi-el
Copy link

gi-el commented Jan 17, 2018

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

@richtong
Copy link

richtong commented Jan 17, 2018 via email

@fedorov
Copy link

fedorov commented Feb 20, 2018

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

@fedorov
Copy link

fedorov commented Feb 20, 2018

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

@ikhere
Copy link

ikhere commented Feb 24, 2018

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.
.

@OnkelTem
Copy link

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

@peckhouse
Copy link

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

@sprive
Copy link

sprive commented Mar 2, 2018

Hey all - this worked for me, on High Sierra:

$ mkdir ~/etc
$ vi ~/etc/timezone
$ cat ~/etc/timezone
America/New_York

Then my docker-compose.yml mount looks like:

$ grep -C2 timezone docker-compose.yml 
      volumes:
        - /Users/sprive/home-assistant/localdata:/config
        - ~/etc/timezone:/etc/localtime:ro
      restart: always
      network_mode: host

Some thoughts:

  • I don't know (and don't care) why it doesn't work anymore on OSX. If you never change timezones the above is OK. If NOT...
    • There are other ways (like .env) to get TZ string into your container, if you don't like this way. You do not have to be blocked by this.
    • NOTE: if trying another way, try to keep it at the mount or ENV level (so it's runtime... rather than embed it into the image, which would work - but isn't a a good technique.. )

@t0sche
Copy link

t0sche commented Mar 7, 2018

@sprive this worked for me. Thanks!

@lacvapps
Copy link

Commenting to say this is still an issue on High Sierra, latest Docker for mac

@harshashinde
Copy link

+1

@Nottt
Copy link

Nottt commented Apr 4, 2019

So this is why my docker users had issue with this. I'd prefer if docker and OS X could just keep /etc/localtime to be cross-platform friendly.

But if you can contact the docker owner, all he needs to do is add something like this to the dockerfile to support other platforms

RUN apt-get update && apt install -y tzdata and then start the container with a variable like -e TZ=America/New_York

If you can't fix this at source, just clone the docker repo in your machine, edit the Dockerfile locally, then build the docker again with that Dockerfile and run it with that variable.

Should work for people that don't have /etc/localtime. But I'd just use linux :P

@lizilong007
Copy link

@Gengar003 Thank you.

The best way is to use the lower version...

@LimEunji
Copy link

I downgraded docker version to 17.09.1-ce-mac42 (21090) and solved this problem. ㅠ_ㅠ

@umertauheedkhan
Copy link

Hey all - this worked for me, on High Sierra:

$ mkdir ~/etc
$ vi ~/etc/timezone
$ cat ~/etc/timezone
America/New_York

Then my docker-compose.yml mount looks like:

$ grep -C2 timezone docker-compose.yml 
      volumes:
        - /Users/sprive/home-assistant/localdata:/config
        - ~/etc/timezone:/etc/localtime:ro
      restart: always
      network_mode: host

Some thoughts:

  • I don't know (and don't care) why it doesn't work anymore on OSX. If you never change timezones the above is OK. If NOT...

    • There are other ways (like .env) to get TZ string into your container, if you don't like this way. You do not have to be blocked by this.
    • NOTE: if trying another way, try to keep it at the mount or ENV level (so it's runtime... rather than embed it into the image, which would work - but isn't a a good technique.. )

It worked for me...

@631068264
Copy link

631068264 commented Jun 18, 2019

It's very easy to solve just cat /etc/localtime > path you want

docker-compose.yml

    volumes:
      - path you want:/etc/localtime

usedate -R to check in container default is +0000

All the method above I have tried, nothing work for me and thanks for contributers

@carlosonunez
Copy link

carlosonunez commented Jul 16, 2019

An alter

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

An alternative to this is -e TZ=Etc/GMT$(date +%z). This should be POSIX-compliant and work with any Linux or BSD-based container.

@christopherbowers
Copy link

My container worked until yesterday and now it fails. I'm not sure what has changed.

sdake pushed a commit to sdake/operator that referenced this issue Aug 5, 2019
reallink is a non-existing command.  I had confused it for realpath.
However, what I had mean to use was readlink.

See:
docker/for-mac#2396 (comment)
istio-testing pushed a commit to istio/operator that referenced this issue Aug 5, 2019
reallink is a non-existing command.  I had confused it for realpath.
However, what I had mean to use was readlink.

See:
docker/for-mac#2396 (comment)
@liujiaming19910220
Copy link

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)

It's the simplest method but worked

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@whathejoe
Copy link

/lifecycle frozen

@whathejoe
Copy link

/remove-lifecycle stale

xgt001 added a commit to xgt001/pytradfri that referenced this issue Dec 26, 2019
When TZ is not explicitly specified, docker on mac throws up this nice error by default:
```
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.
```
Refer this upstream docker for-mac upstream issue for details: docker/for-mac#2396
This tiny improvement makes onboarding easier for mac folks who don't want to install libcoap maybe?
ggravlingen pushed a commit to home-assistant-libs/pytradfri that referenced this issue Jan 2, 2020
When TZ is not explicitly specified, docker on mac throws up this nice error by default:
```
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.
```
Refer this upstream docker for-mac upstream issue for details: docker/for-mac#2396
This tiny improvement makes onboarding easier for mac folks who don't want to install libcoap maybe?
@liesai
Copy link

liesai commented Jun 14, 2020

Had this issue because /etc/ repository wasn't shared with docker. You just have to add this repository in the Resources menu -> FILE SHARING from the docker UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests