0

I am trying to setup a development environment based on Visual Studio Code. The goal is to write and debug Python code that executes in a remote Docker container.

This is what I did: I installed Visual Studio Code Insiders, the Python extension, and the Remote Development extension (3 extensions in 1), setup SSH on both the remote computer (which runs Linux, and for which I am a sudoer) and mine (which runs Windows). So now I am able to connect to this remote computer via SSH and execute Python code on it. These features are already incredible but I need more.

On this remote machine there is a Docker service running, and I would like to be able to execute Python code with the Python interpreter inside some Docker container, not with the Python interpreter of the remote computer. So I downloaded the Docker extension not on my computer but on the remote computer (that was proposed by Visual Studio Code) and then changed the settings.json file to:

{
    "remote.extensionKind": {
        "peterjausovec.vscode-docker": "workspace"
    }
}

according to what is stated here, section Docker Extension limitations. Then, after clicking on the Docker button on the left, I can see a list of all containers running on the remote computer, that's really great.

But when I try to attach Visual Studio Code to one of these containers, it fails to find the Docker daemon. After reading the documentation of the Docker daemon here, I restarted the Docker daemon with the option -H tcp://0.0.0.0:22 or -H tcp://0.0.0.0:2375 in order for the daemon to be able to listen to requests made remotely from my computer. The first one didn't work at all (the daemon didn't start), the second one works (the daemon starts). However, I still can't attach Visual Studio Code to my container (Visual Studio Code still can't find the daemon).

Any help would be greatly appreciated!

  • 1
    Any particular reason you'd like to develop in a Docker container? Docker containers are for packing things up so your application always sees the same environment. Usually you develop and test locally, and then do automatic deployment, which produces a Docker container. – dirkt May 21 at 10:58
  • @dirkt: I see your point, but this is what I am required to do for the moment :) Perhaps one reason is that other people didn't want me to install Spark on the remote machine and instead wanted me to use right away a Docker image with Spark already installed in it. – bcoueraud87 May 21 at 11:16
  • 1
    So can you install Visual Studio in the Docker container itself? Enable X forwarding and ssh into the container. That won't be particular fast... and of course it will pollute the container with the development environment. Or can you make at least a "development" container with Visual Studio, and a "production" container with the final product? Also, a container is a container, so I guess you could run the "development" container locally on your Windows machine... – dirkt May 21 at 11:56
0

The problem was that I had an old version of Docker, I needed version 18.09 for enabling SSH communication with the Docker daemon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.