dockervscode-devcontainer

fix docker file in vscode devcontainer after a bad change


I am learning how to work with Docker and VSCode Devcontainers on WSL2, and had a working docker file. Now I've made a change, and it refuses to rebuild the container. How can I find the docker file and edit it to restore it back to a working condition?

I do see documentation of a Recovery container, but nothing like that shows up in my VSCode 1.84.2 and using Dev Containers v0.321.0.

This container is tracked in a git repository, but it was created using the command palette Create Dev Container functionality, and never explicitly saved to a known directory. Without having an explicit location, and having made more changes than I should in a single commit, I'd really like to recover this if possible.


Solution

  • I was able to see the volume in the Docker Desktop app with all the files, including the Dockerfile that needed fixing.

    Following another post, I was able to go to \\wsl$\docker-desktop-data\data\docker\volumes, and navigating in this folder structure find my .devcontainer\Dockerfile to edit and remove the broken commands that blocked the container from launching.

    It looks like depending on the version you're running this folder path might vary slightly if others run into this issue, and I suggest taking a look at the linked answer above.