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

Setting workdir as subdirectory of mounted directory fails #32708

Open
ewanbarr opened this issue Apr 19, 2017 · 4 comments
Open

Setting workdir as subdirectory of mounted directory fails #32708

ewanbarr opened this issue Apr 19, 2017 · 4 comments
Labels
area/runtime kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/17.03

Comments

@ewanbarr
Copy link

Description

The documentation for the "-w" flag on docker create/run states that the directory will be created if it does not already exist. This does not appear to work when the requested workdir is a subdirectory of a mounted volume.

The error returned is always:

Starting container process caused "chdir to cwd (\"some directory") set in config.json failed: no such file or directory

This looks like an order of operations issue, where chdir is called ahead of the volume creation. It is not clear if this is a bug/feature/limitation of the system.

Steps to reproduce the issue:

  1. Make sure "/tmp/random-directory-name" does not exist on your system
  2. docker run -v /tmp/:/tmp/ -w /tmp/random-directory-name/ ubuntu:16.04

Describe the results you received:

This returns the following:

container_linux.go:247: starting container process caused "chdir to cwd (\"/tmp/random-directory-name\") set in config.json failed: no such file or directory"
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "chdir to cwd (\"/tmp/random-directory-name\") set in config.json failed: no such file or directory".

Describe the results you expected:

I would expect Docker to first mount the volume, create the subdirectory then set the working directory.

Additional information you deem important (e.g. issue happens only occasionally):
N/A

Output of docker version:

Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:00:50 2017
 OS/Arch:      linux/amd64
 Experimental: true

Output of docker info:

Containers: 7
 Running: 0
 Paused: 0
 Stopped: 7
Images: 630
Server Version: 17.03.1-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 241
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.13-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952 GiB
Name: moby
ID: 6RTM:GORH:OK2Y:5NR6:UBS6:PRRO:BCQP:SUFM:QUZW:XLV5:I46E:7RBV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 17
 Goroutines: 28
 System Time: 2017-04-15T16:09:06.80608598Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Username: mpifrpsr
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

Same behaviour also seen on native Linux box running:

Distributor ID:	Debian
Description:	Debian GNU/Linux 8.7 (jessie)
Release:	8.7
Codename:	jessie
@cpuguy83
Copy link
Member

While the UX is kind of ugly on this... I'm not sure I agree with the use-case.
The mounted directory is something you passed in and should be your responsibility to make sure everything exists.

@cpuguy83 cpuguy83 added the kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. label Apr 22, 2017
@ewanbarr
Copy link
Author

That's reasonable. However, whatever the intended behaviour is, it should be captured in the docs.

@ClayAndMore
Copy link

i meet the question, as same as your say.

@sorenmat
Copy link

sorenmat commented Apr 3, 2018

I'm experiencing this issue, even if the directory exists.
So if i mount /mydir and then set the workingdir to /mydir/A and A does exist, I still get the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/17.03
Projects
None yet
Development

No branches or pull requests

5 participants