microsoft / vscode-docker

Docker Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker
Other
1.19k stars 508 forks source link

Unable to Set Custom Docker Executable Path #4198

Closed byteshiva closed 5 months ago

byteshiva commented 6 months ago

Description: Unable to set a custom Docker executable path (docker.executablePath) in the settings if it already exists. This prevents customization of Docker executable paths.

Steps to Reproduce:

  1. Open settings.json.
  2. Set docker.executablePath to a custom path (e.g., "/home/xyz/.fly/bin/docker").
  3. Save settings.
  4. Observe that the Docker extension defaults to the system path, ignoring the custom path.

Expected Behavior: One should be able to set a custom Docker executable path. (Especially in Exceptional Cases like Flatpak Visual Studio Code)

Proposed Solution: Permit setting docker.executablePath in the current settings, provided it makes logical sense in the context.

Additional Note: There is no documentation(maybe i'm missing something here) on setting the containerCommandfor Docker commands. Including this information would improve clarity.

Note: -- containerCommand - I guess that it may be dynamically set at runtime from "env: withDockerEnvSettings(process.env)""."

Configuration:

{
    "docker.executablePath": "/home/xyz/.fly/bin/docker", // if this exists in current settings
    // Other Docker configurations...
}

or

{
    "docker.commands.build": "${containerCommand} build --pull --rm -f \"${dockerfile}\" -t ${tag} \"${context}\"",
    "docker.commands.run": "${containerCommand} run --rm -d ${exposedPorts} ${tag}",
    "docker.commands.composeDown": [
        {
            "label": "Compose Down",
            "template": "${composeCommand} ${configurationFile} down"
        }
    ],
    "docker.composeCommand": "flatpak-spawn --host docker-compose",
    "docker.dockerPath": "flatpak-spawn --host docker",
    "workbench.settings.applyToAllProfiles": [
        "docker.dockerPath",
        "docker.composeCommand"
    ],
    "docker.executablePath": "/home/xyz/.fly/bin/docker", // if this exists in current settings
}

Related: I'm trying to recreate the following scenario: https://github.com/microsoft/vscode-docker/issues/3788#issuecomment-1370345414

$ flatpak run --command=bash --filesystem=host com.visualstudio.code
[📦 com.visualstudio.code ~]$ echo $PATH
/home/xyz/.fly/bin:/app/bin:/usr/bin
[📦 com.visualstudio.code bin]$ ls -rlt 
total 72124
-rwxr-xr-x 1 xyz users 73851200 Jan  3 01:23 flyctl
lrwxrwxrwx 1 xyz users       26 Jan  4 18:33 fly -> /home/xyz/.fly/bin/flyctl
-rw-r--r-- 1 xyz users        0 Jan  4 18:33 diole
lrwxrwxrwx 1 xyz users       22 Jan  4 18:34 docker -> /home/xyz/docker.sh
### Tasks
- [ ] https://github.com/microsoft/vscode-docker/issues/3788#issuecomment-1370345414
bwateratmsft commented 5 months ago

docker.executablePath is not a setting that exists so I'm not sure why you're expecting it to work. The setting you're looking for is docker.dockerPath, which is intentionally allowed to contain spaces so that more complex scenarios can be used, provided the right shell quoting is in place.

{containerCommand} and {composeCommand} are documented here