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

stream config option changes docker.cli.exec() behavior #303

Open
ColinMcNeil opened this issue Jan 27, 2025 · 0 comments
Open

stream config option changes docker.cli.exec() behavior #303

ColinMcNeil opened this issue Jan 27, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ColinMcNeil
Copy link

ColinMcNeil commented Jan 27, 2025

Describe the bug
In the docker.cli.exec() function, the third argument allows specifying options. Using a truthy object option for { stream: {} } changes how the args are escaped. This means I'm unable to escape paths for bind mounts when streaming stdio.

Steps to reproduce the behavior:

  1. Run a demo extension
  2. In frontend, use
const client = createDockerDesktopClient();
  1. Verify the following works:
client.docker.cli.exec('run', ['--mount', `type=bind,source="some-path-with-quotes",target=/file`, 'alpine:latest', 'sh', '-c', `"cat file"`]).then(console.log).catch(console.error)
  1. Try the same command with stream set
client.docker.cli.exec('run', ['--mount', `type=bind,source="some-path-with-quotes",target=/file`, 'alpine:latest', 'sh', '-c', `"cat file"`], {
  stream: {
    onError(e) {
      console.error(e)
    }
  }
})

Describe the expected behavior
Normally, the function will run and return file contents via output.stdout as you would expect. However, when you specify anything for stream, we see

invalid argument "type=bind,source=\"/Users/$USER/my-file.json\",target=/config.json" for "--mount" flag: parse error on line 1, column 18: bare " in non-quoted-field
See 'docker run --help'.

Optional: Add screenshots
If applicable, add screenshots to help explain your problem.

**Output of docker extension version:

Client Version: v0.2.27
Server API Version: 0.3.4

Output of docker version:

Client:
 Version:           27.5.1
 API version:       1.47
 Go version:        go1.22.11
 Git commit:        9f9e405
 Built:             Wed Jan 22 13:37:19 2025
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.38.0 (181016)
 Engine:
  Version:          27.5.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.11
  Git commit:       4c9b3b0
  Built:            Wed Jan 22 13:41:25 2025
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.7.25
  GitCommit:        bcc810d6b9066471b0b6fa75f557a15a1cbf31bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e946
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
@ColinMcNeil ColinMcNeil added the bug Something isn't working label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant