How to re-open a repository cloned in a volume, from Visual Studio Code

I love Dev Containers, I use them a lot for most of my development. One of my favorite options is to clone a repository directly in a docker volume.

It takes a few seconds and you can work on your code without installing any SDKs or language that your current machine doesn't have. Marvelous!

Ideally, at the end of your session, you push your code to another repository (ex: GitHub). However, sometimes I forget or am interrupted I start working on something else, and my changes are not pushed.

How do you re-open that environment?! In this post, I want to share two ways that I use.

Open Recent

The first method is to use the history of the editor! For example, here in Visual Studio Code, select the File menu and Open Recent.

If you didn't open too many files since you used that dev container, it should be present as displayed in the image. It should look like: <Name of the repository> in a unique [Dev Container].

Make sure docker is already running and select it. Voila, in a snap you are back into the dev environment with your last changes waiting for you.

Open the Container

There are a few different options to do the next solution, I will share the one I consider the easiest for the people who are not Docker experts.

First, if not already present to your VSCode, add the Docker extension identifier: ms-azuretools.vscode-docker. Then from this new extension in the top section named containers search for your container. It should start with "vsc", for Visual Studio Code, then hyphen the name of the repository you cloned. Right-click on it and select start. After a few seconds, the container should have a little green triangle on its side and be ready to continue.

The next step consists of attaching the container to VSCode. Once more, from the Docker extension, right-click on the container and select Attach Visual Studio Code.

This will open a new VSCode window, we are mostly done but there is one last step to do. You will notice that the file explorer is empty. No worries we will fix everything with this last step. The terminal should be open in the home folder of the root user. Let's open our project folder by executing the command:

cd /workspaces/<repository-name>

Then the final command is to re-open VSCode in this folder and let the Dev Container do his magic. Execute the command:

code . -r

(the -r is to re-use the same VSCode windows. It's optional, if not provided it will open a new VSCode instance.)

And voila! The Dev Container is just as it was before.

If you know other ways to achieve this, leave a comment or reach out, I'm always happy to learn more.

~ frank

Reading Notes #506

Good Monday, Already time to share my reading notes of the week. A list of all the articles, and blog posts, that catch my interest during the week.

If you think you may have interesting content, share it!




  • Docker Desktop for Linux is Here! (DevOps and Docker Talk) - Great episode so much energy! Discussion about the brand new Docker Desktop for Linux, who to report bugs, ask for a new feature, and the DockerCon!
  • Épisode 15 - Gengis Khan (Les Pires Moments de l'Histoire) - I keep those episodes very preciously as a threat, and this one was such a good one! It's in French and the topic is the biggest empire that ever existed... No, it's the Romain.
  • How to Productively Show Off What You've Learned (Modern Mentor) - Nice episode. That's a good idea I should share what I think of books and posts I read! ;) I guess I'm not too bad.
  • Comparing Infrastructure-as-Code with Chris Klug (.NET Rocks!) - Terraform, Pulumi, ARM, and Bicep... All those are mentioned because it's all about Infrastructure-as-Code. Interesting talk about the different options we have.



Reading Notes #505

Me, thinking I could work with the dogs

Good Monday, Already time to share new reading notes. Here is a list of all the articles, blog posts, and podcast episodes that catch my interest during the week.

If you think you may have interesting content, share it!