10

I need to edit a file in a docker container. as no advanced ide inside the container,I wonder if vscode or some other ide can access into the container and let me edit files as outside the container.

curtank
  • 600
  • 2
  • 7
  • 18
  • the only thing i need is to edit, no debug request involved. – curtank Nov 14 '18 at 03:07
  • Remember that, when you `docker rm` the container, any change you make this way is lost; and you need to delete and recreate the container to make a variety of very routine changes (port mappings, environment variables, newer image). It's better to make the change in the image build or push things like config files in using bind mounts (`docker run -v` option). – David Maze Nov 14 '18 at 04:52

4 Answers4

8

With the May, 2nd 2019 announcement of "Remote Development with VS Code", you actually can use The Remote - Containers extension :

https://microsoft.github.io/vscode-remote-release/images/remote-containers-readme.gif

The Remote - Containers extension lets you use a Docker container as a full-featured development environment.

Containers make a great development environment because you can:

  • Develop with a consistent and easily reproducible toolchain and on the same operating system you are deploying to.
  • Quickly swap between different, isolated development environments and safely make updates without worrying about impacting your local machine.
  • Make it easy for new team members / contributors to get up and running in a consistent development environment.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

Docker Workspace makes enabled to add folder inside a running docker container.

enter image description here

Arbaoui Mehdi
  • 754
  • 6
  • 18
2

Docker extension for VS Code (ms-azuretools.vscode-docker) allows you to right-click on any running container in the list, then choose 'Attach Visual Studio Code' - and you will be able to open any folder inside Docker container in a new VS Code window. I presume you must have The Remote - Containers extensions installed as well.

Yaroslav Larin
  • 209
  • 2
  • 6
-2

Start the container by mapping the host path with container path using -v

docker run -v ~/yourlocalpath:/dockerpath

Changes you make on this folder will be reflected inside.

Ganesh Chandrasekaran
  • 1,578
  • 12
  • 17