Home > database >  VSCode how to open a local folder within a local docker container.....without devcontainers.json?
VSCode how to open a local folder within a local docker container.....without devcontainers.json?

Time:10-19

I want start a docker container that I have created, and then mount a local folder to it in a way that doesn't make use of a devcontainers.json file. This is because I would like to test the same local repo out with multiple docker containers and editing the devcontainers.json file is a pain because I have to edit every time I want to change the docker image - where really I just want to do something like:

  1. Dev Containers: Open Local Folder in Container
  2. Choose Local Folder
  3. Choose a docker container that is already running

The problem is that in step 3 I only see options to choose from pre-made base images i.e. Ubuntu 22.04. I can't see anywhere in the list any of my docker containers that I am running. Have I missed any functionality? Does what I'm asking exist......or must I use a devcontainers.json file?

CodePudding user response:

If I correctly understood your issue:

Once you install Microsoft's Docker extension from the VS Code extensions' tab (ctrl shift x), you'll be able to do that. Microsoft's Docker Extension

This extensions have a "CONTAINERS" tab, where you can open another VSCode window inside a selected container's directory or attach a terminal to the container and manage the system. Docker extension's containers' tab

Just right-click on the desired container and you'll see the options.

  • Related