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.
-
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 Answers
With the May, 2nd 2019 announcement of "Remote Development with VS Code", you actually can use The Remote - Containers extension :
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.

- 1,262,500
- 529
- 4,410
- 5,250
Docker Workspace makes enabled to add folder inside a running docker container.

- 754
- 6
- 18
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.

- 209
- 2
- 6
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.

- 1,578
- 12
- 17
-
1It still has to be rebuilt right? Is there an option that as soon as changes are made, the container will reflect it? – Visakh Vijayan May 19 '20 at 07:59