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

Emit some information about what target the Docker extension is trying to connect to #2493

Closed
webdog opened this issue Nov 12, 2020 · 5 comments · Fixed by #2513
Closed

Emit some information about what target the Docker extension is trying to connect to #2493

webdog opened this issue Nov 12, 2020 · 5 comments · Fixed by #2513

Comments

@webdog
Copy link

webdog commented Nov 12, 2020

Version: 1.51.0
Commit: fcac248b077b55bae4ba5bab613fd6e9156c2f0c
Date: 2020-11-05T18:14:40.758Z (1 wk ago)
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.4.0

  • VSCode Version: 1.51.0
  • Local OS Version: 10.15.4
  • Remote OS Version: N/A
  • Remote Extension/Connection Type: SSH/Docker/WSL Docker

Steps to Reproduce:

  1. Edit docker.host to tcp://$docker_host_ip:2376
  2. Refresh Containers

Does this issue occur when you try this locally?: Yes/No Yes
Does this issue occur when you try this locally and all extensions are disabled?: Yes/No Yes

I am setting docker.host to connect to my local installation of Docker for Desktop on Mac, which works and can connect with no issue independently of VSCode. However VSCode complains that it cannot verify the first certificate:
image
image
image
image

(base) ➜  echo $PATH
/Users/christianweber/opt/anaconda3/bin:/Users/christianweber/opt/anaconda3/condabin:/opt/anaconda3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
(base) ➜  docker-machine env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/christianweber/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell: 
# eval $(docker-machine env)

(base) ➜  env (output edited for brevity)
SHELL=/bin/zsh
DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_CERT_PATH=/Users/christianweber/.docker/machine/machines/default
DOCKER_MACHINE_NAME=default

(base) ➜  docker-machine ip
192.168.99.100

(base) ➜  ping 192.168.99.100
PING 192.168.99.100 (192.168.99.100): 56 data bytes
64 bytes from 192.168.99.100: icmp_seq=0 ttl=64 time=0.314 ms
64 bytes from 192.168.99.100: icmp_seq=1 ttl=64 time=0.268 ms

(base) ➜  docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                      NAMES
b4ecef67142b        webdog              "/docker-entrypoint.…"   2 hours ago         Up 2 hours          80/tcp, 8000/tcp, 0.0.0.0:8080->8080/tcp   peaceful_hamilton

Console logging does not provide any debug logging when displaying the front-end certificate error:
image

Additionally, trying to enter just the IP address of the local host results in a formatting error:
image
image
image

I think I have two questions:

  • Is it necessary to have certificate verification on a local install of Docker?
  • Is the certificate check occurring because this docker_host isn't set to localhost?
@webdog webdog changed the title Docker extension does not show running containers or images from local docker installation Docker extension does not show running containers or images from local docker installation on macOS Nov 12, 2020
@webdog
Copy link
Author

webdog commented Nov 14, 2020

Resolved on my own. For historical accuracy, what looks like happened here was that I had previously installed and configured docker with brew and later on installed with Docker for Desktop (Error on my part). I only noticed this when comparing the network devices in the VSCode extension, with docker network ls and inspecting the bridge.json file between both the CLI.

Additionally, it seems that VSCode's Docker extension binds itself to /var/run/docker.sock before anything else. My brew installed version of docker was running a docker socket elsewhere inside of my homedir.

image

However, I am bit unsatisifed that there isn't necessarily a clear way in the extension to ascertain the default host it's connecting to, without diving into the Context Pane's default config (There weren't any breadcrumbs that led me here to understand this is where the socket was configured). I would have expected this setting/configuration to have been presented in User Settings. I could be wrong in that thought, but it was my first thought when working through it.

In the Context pane, it says it's defaulting to Current DOCKER_HOST based configuration, which in my case was untrue, as it was binding to a specific DOCKER_HOST configuration which I could not find on my system. (I tried /bin/sh, /bin/bash/ and /bin/zsh, all were pointing to the brew installed version of Docker.). I did not try binding to a new socket, instead opting to remove both versions of Docker, and starting anew. This fixed it.

image

As a feature suggestion, I'd ask configuration of a docker host and socket be configurable in the User/Workspace settings, as there wasn't sufficient troubleshooting data or VSCode logging to understand which docker it was connected to. The Extension docs also didn't provide a whole lot of info on troubleshooting connectivity issues (And yes, I'll freely admit, this is a user error and probably an edge case 😺 )

Extension is working now, but I will leave this issue open for feedback 👍

@chrmarti chrmarti transferred this issue from microsoft/vscode-remote-release Nov 16, 2020
@bwateratmsft
Copy link
Collaborator

@webdog The docker.host setting does permit sockets as well as addresses; for example you could do unix:///var/run/docker.sock (which is what is used by default). We don't that default value there because on Windows it is instead npipe:////./pipe/docker_engine. As far as I know there's no way for extension authors to specify different default values per OS. As you found though, we implicitly use those values as defaults; indeed it seems most people are set up that way (and the remainder are mostly SSH).

As for the invalid URL issue, Dockerode, which we're using for connecting to Docker, requires a full URL including protocol (and in the case of SSH, username as well), which is why it won't accept 1.2.3.4:2376, but does accept tcp://1.2.3.4:2376.

We could emit information to the Output window about where Docker is trying to connect to, but other than that I don't think there's a better place to give such info.

@webdog
Copy link
Author

webdog commented Nov 16, 2020

As far as I know there's no way for extension authors to specify different default values per OS.

That's a really good point. Even if it did, it could become confusing quickly unless those values were nested/organized in some efficient way (Something like system.docker.config.[windows|osx|linux] as a passing thought). I also say that without understanding the effort required to support that, which could be considerable.

We could emit information to the Output window about where Docker is trying to connect to, but other than that I don't think there's a better place to give such info.

Information in the output window would work, I think. It would have been a breadcrumb for me that my environment was misconfigured. In my case, my DOCKER_HOST was the IP, and if I'd seen the variable was set to the value of the Socket, I may have been able to use that info to investigate further, and understand quickly that I had two Docker installations set up (oops!)

Thanks again! I'm good with closing this out as a suggestion/feature request for a little more logging 😺

@bwateratmsft
Copy link
Collaborator

I'll adjust the title and set some labels. Thank you for the suggestion and for the very detailed information!

@bwateratmsft bwateratmsft changed the title Docker extension does not show running containers or images from local docker installation on macOS Emit some information about what target the Docker extension is trying to connect to Nov 16, 2020
@dbreshears dbreshears added this to the 1.9.0 milestone Nov 18, 2020
@dbreshears dbreshears added the P2 label Nov 18, 2020
@bwateratmsft bwateratmsft removed their assignment Nov 23, 2020
@bwateratmsft
Copy link
Collaborator

This is now available in Docker extension version 1.9.0.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants