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

open /.docker/.token_seed: permission denied #1936

Closed
rittneje opened this issue Jan 6, 2021 · 15 comments · Fixed by #2234
Closed

open /.docker/.token_seed: permission denied #1936

rittneje opened this issue Jan 6, 2021 · 15 comments · Fixed by #2234
Milestone

Comments

@rittneje
Copy link
Contributor

rittneje commented Jan 6, 2021

While testing out the 0.8.1 rootless image, I encountered the following build error:

error: failed to solve: rpc error: code = Unknown desc = open /.docker/.token_seed: permission denied

From looking at the source code it appears that the token seed file logic is only checking against syscall.EPERM and not syscall.EACCES, so a permission failure is fatal. You should switch to os.IsPermission(err) instead of using errors.Is(err, syscall.EPERM), since this will account for both syscall.EPERM and syscall.EACCES.

@tonistiigi tonistiigi added this to the v0.8.0 milestone Jan 7, 2021
@tonistiigi
Copy link
Member

Thanks for the report. How did you hit this?

@rittneje
Copy link
Contributor Author

rittneje commented Jan 7, 2021

In my Dockerfile, the /.docker folder was created by root. (It was really created as a side effect of a COPY instruction, which ignores the contextual uid/gid, unlike RUN.) Consequently, uid 1000 did not have write permission to the folder, so attempting to create the /.docker/.token_seed file failed.

@thaJeztah thaJeztah modified the milestones: v0.8.0, v0.8.2 Feb 4, 2021
@theokrammer
Copy link

I had the same error, though for me this occurs when accessing an image directly from docker hub using 'FROM ...'. Not sure it has anything to do with this, and the error disappears after i manually run a 'docker pull ...'. It is not limited to the image used here (alpine) but for everything. Is this happening for anybody else? I am on macOS Big Sur if that matters.

@karlismelderis
Copy link

I got same error.
For now docker pull ... helped but I'm not sure yet if error is gone for good.

@tonistiigi
Copy link
Member

#2050

@rittneje
Copy link
Contributor Author

rittneje commented Jun 11, 2021

@tonistiigi I don't think this issue is fixed. The PR you linked seems unrelated.

@tonistiigi tonistiigi reopened this Jun 11, 2021
@tonistiigi
Copy link
Member

@rittneje maybe indeed. #1745 is also related. But if your issue is that something(not docker itself) corrupted your docker config and now it is unreadable to docker binary then there isn't really anything we can do about it. The config dir needs to be fixed.

The PRs cover similar cases that could appear from system crashes or readonly volumes. As these are cases that can appear without explicit config directory corruption.

@rittneje
Copy link
Contributor Author

My docker config was not corrupted. The uid running buildkit just does not have write permission to the directory. #1745 missed checking for syscall.EACCES, hence this bug.

@tonistiigi
Copy link
Member

Docker config is per-user. The user invoking docker should always have access to their own config dir.

@rittneje
Copy link
Contributor Author

They should have read access. Needing write access outside docker login is pretty unexpected to be honest. And in any case you already added support for it being on a read-only file system. Also, with the DOCKER_CONFIG environment variable in play, the config dir may not necessarily belong to the user anyway.

@ninanung
Copy link

I'm getting same error from Docker for Apple silicon.

@AliF50
Copy link

AliF50 commented Aug 26, 2021

I had to manually pull the images like the user's mentioned here to fix the issue.

I am on macOS Big Sur 11.5.1 and docker version 20.10.8, build 3967b7d.

@Cartmanishere
Copy link

Cartmanishere commented Oct 20, 2021

Faced the same issue so just added rw permission to the required files.

chmod 666 .token_seed .token_seed.lock

Not sure what's the impact of this but solved my error for now.

@spuder
Copy link

spuder commented Dec 24, 2021

@Cartmanishere 666 means that anyone on your computer could read and write to that file.
On my machine the permissions are currently 600

-rw-------  1 root  staff  74 Dec 24 11:53 /Users/spuder/.docker/.token_seed

A safer option would be 660

chmod 660 .token_seed .token_seed.lock

@Shahriar-Sazid
Copy link

I faced the same problem then prepended sudo before the command and that fixed the problem

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

Successfully merging a pull request may close this issue.

10 participants