docs
docs copied to clipboard
Permission denied mounting a volume via docker run in a NON existing folder in the host
Is this a docs issue?
- [X] My issue is about the documentation content or website
Type of issue
Information is incorrect
Description
In the documentation is indicated
docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
When the host directory of a bind-mounted volume doesn't exist, Docker automatically creates this directory on the host for you. In the example above, Docker creates the /doesnt/exist folder before starting your container.
I get an error
docker: Error response from daemon: error while creating mount source path 'XXX/doesnt/exist': chown 'XXX/doesnt/exist: permission denied. ERRO[0000] error waiting for container:
It's truth that
- folder is created -- Example: run
lsto check -- - container has run --
docker ps --all--
👁️ but the command itself passed -- docker run ... bash -- has failed 👁️
Notes:
- Stack
- docker client
- 24.0.2-rd
- API: 1.42
- docker server engine
- 23.0.6
- API: 1.42
- OS: macOS Sonoma v14.3, intel
- docker client
Location
https://docs.docker.com/reference/cli/docker/container/run/#volume
Suggestion
- Is there some way to give the permissions to that folder automatically created by Docker to avoid getting the error?
- If you run the same command again, it works ... 🤔
- If there is NO way to get the command succeed -> I would specify in this section of the documentation, because it can confuse to the reader of the documentation, such as
When the host directory of a bind-mounted volume doesn't exist, Docker automatically creates this directory on the host for you. In the example above, Docker creates the /doesnt/exist folder before starting your container, although in the output of the command you get an error
Maybe @dvdksn ?
There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.
Prevent issues from auto-closing with a /lifecycle frozen comment.
/lifecycle stale