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

invalid mount config for type "volume" #749

Closed
yuyaogawa opened this issue Aug 25, 2021 · 8 comments · Fixed by #751
Closed

invalid mount config for type "volume" #749

yuyaogawa opened this issue Aug 25, 2021 · 8 comments · Fixed by #751
Assignees
Labels
area/windows kind/bug Something isn't working
Milestone

Comments

@yuyaogawa
Copy link

yuyaogawa commented Aug 25, 2021

I get an error below when creating container. I am new to docker. Do you have any ideas to solve the error?

$ docker buildx inspect --bootstrap
#1 [internal] booting buildkit
#1 pulling image moby/buildkit:buildx-stable-1
#1 pulling image moby/buildkit:buildx-stable-1 4.4s done
#1 creating container buildx_buildkit_mybuilder0 0.1s done
#1 ERROR: Error response from daemon: invalid mount config for type "volume": invalid mount path: 'C:/ProgramData/buildkitd/.buildstate' mount path must be absolute
------
 > [internal] booting buildkit:
------
Name:   mybuilder
Driver: docker-container

Nodes:
Name:     mybuilder0
Endpoint: npipe:////./pipe/docker_engine
Error:    Error response from daemon: invalid mount config for type "volume": invalid mount path: 'C:/ProgramData/buildkitd/.buildstate' mount path must be absolute

Docker :

Client:
 Cloud integration: 1.0.17
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:58:50 2021
 OS/Arch:           windows/amd64
 Context:           desktop-linux
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:52:10 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

OS : Windows 10 Home

@spiro-c
Copy link

spiro-c commented Aug 25, 2021

+1
I struggle for two days but if i make the builder from wsl2 the error is not present
from windows power shell

❯ docker --version
Docker version 20.10.8, build 3967b7d
❯ docker buildx inspect --bootstrap
[+] Building 0.0s (1/1) FINISHED
 => ERROR [internal] booting buildkit                                                             3.3s
 => => pulling image moby/buildkit:buildx-stable-1                                                3.3s
 => => creating container buildx_buildkit_mybuilder0                                              0.0s
------
 > [internal] booting buildkit:
------
Name:   mybuilder
Driver: docker-container

Nodes:
Name:     mybuilder0
Endpoint: npipe:////./pipe/docker_engine
Error:    Error response from daemon: invalid mount config for type "volume": invalid mount path: 'C:/ProgramData/buildkitd/.buildstate' mount path must be absolute

From Ubuntu WSL2

❯ uname -a
Linux DESKTOP-HS5PI9S 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
❯ docker --version
Docker version 20.10.8, build 3967b7d
❯ docker buildx inspect --bootstrap
[+] Building 4.5s (1/1) FINISHED
 => [internal] booting buildkit                                                                     4.4s
 => => pulling image moby/buildkit:buildx-stable-1                                                  3.7s
 => => creating container buildx_buildkit_wslbuildr0                                                0.7s
Name:   wslbuildr
Driver: docker-container

Nodes:
Name:      wslbuildr0
Endpoint:  unix:///var/run/docker.sock
Status:    running
Platforms: linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6

@kmpm
Copy link

kmpm commented Aug 25, 2021

I can only confirm and also checked that then folder C:\ProgramData\buildkitd doesn't even exist.
Works from WSL2, Fails from PowerShell.

@tonistiigi tonistiigi added area/windows kind/bug Something isn't working labels Aug 25, 2021
@tonistiigi tonistiigi added this to the v0.6.2 milestone Aug 25, 2021
@tonistiigi
Copy link
Member

@thaJeztah maybe you know why it would behave like this in windows client and what is the correct mount config in this cases. There are no bind mounts so there should never be any windows paths anywhere.

@thaJeztah
Copy link
Member

thaJeztah commented Aug 27, 2021

Ah, yes, I think I see what's happening. Buildx uses a volume to store the cache for the "container" driver. For that, I see it's using some BuildKit defaults;

Mounts: []mount.Mount{
{
Type: mount.TypeVolume,
Source: d.Name + volumeStateSuffix,
Target: appdefaults.Root,
},
},

Those paths are platform-specific, i.e., buildkitd on Windows (once functional) would be using the Windows location;

var (
Root = filepath.Join(os.Getenv("ProgramData"), "buildkitd", ".buildstate")
ConfigDir = filepath.Join(os.Getenv("ProgramData"), "buildkitd")
)

But buildx is running on the client and the docker-container driver creates a Linux container, so as a result, if the buildx client is running on Windows, it will pick the Windows app settings, an it will try to create a Linux container that has a volume mounted at C:/ProgramData/buildkitd/.buildstate, which, In Linux terms, is not a valid "absolute path" (doesn't start with /).

I think the correct thing to do would be to;

  • use a fixed path for the destination (e.g. /buildkit-buildstate/), which would probably work both for "Linux" and "Windows" containers (that is, once we have a Windows native buildkitd that we can run in a container)
  • configure buildkitd running inside the container to use that path

Or to use separate variables for Linux and Windows appdefaults, so that Buildx can pick the one needed for the container platform (currently: "Linux" only)

@thaJeztah
Copy link
Member

@crazy-max ^^ probably introduced in #672

@thaJeztah
Copy link
Member

I also notice that Windows uses a .buildstate subdirectory for this, whereas Linux uses /var/lib/buildkit. Should both use a subdirectory for this? (to be somewhat more aligned)

Ironically the Windows default is using a dot (.) directory, which seems a very Linux thing to do (to make it a hidden directory).

@thaJeztah
Copy link
Member

Or to use separate variables for Linux and Windows appdefaults, so that Buildx can pick the one needed for the container platform (currently: "Linux" only)

I guess this would not work, because on Windows, the path depends on the %PROGRAMDATA% env-var, which should be resolved to %PROGRAMDATA% on the "destination end" (in this case, the container), so cannot be resolved the client side (unless we hard-code the env-var for the container as well).

@thaJeztah
Copy link
Member

Let me open a quick PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/windows kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants