The Docker Desktop has a number of cool features aimed at making container development more efficient and easier. One such feature is called Dev Environments (still in beta), which allows you to create a configurable development environment using a locally deployed, self-contained container and simplifies the process of sharing code and dependencies with a team and even switching between branches.

Essentially, what you can do is create a development environment (which is created within a docker container) where you can then either open the dev environment in VSCode, inspect the environment, access the command line interface of the running container, and much more.

With Docker Dev Environments, you can either use remote GitHub repositories or those on your local machine. For those who are just getting started on this journey, there’s also a sample environment you can use as a demonstration to get yourself up to speed (which is what we’re going to do). Once you’re accustomed to the Docker Desktop Dev Environment workflow, you can then start working with remote repositories (such as GitHub).

Before we dive into Docker Desktop, there are a couple of things you’ll have to take care of first. As well, you should know that this feature is still in beta, so there will most likely be issues. Obviously, you must have Docker and Docker Desktop installed on your machine. You’ll also need VSCode installed. I’m going to demonstrate on Ubuntu Desktop 22.04 and I’ll help you get VSCode installed and take care of one extra step that must be taken care of before the app will interact with Docker Desktop.

Installing VSCode

The first thing to do is install VSCode. To do that, point your browser to the VSCode site and download the .deb installation file. Once the file has been downloaded, open a terminal window, change into the Downloads directory with the command cd ~/Downloads, and install VSCode with the command:

That installation should go off without a hitch. With VSCode installed, open the app from your desktop menu.

Add the Dev Containers Extension

The next missing piece is the Dev Containers extension. To do that, click on the Extensions tab in the left sidebar and, in the search field (Figure 1), type the following:

Hit Enter on your keyboard and the Dev Containers extension should automatically be added to VSCode. If not, click Install in the Dev Containers description and it should finish the job.

Figure 1: Installing the Dev Containers extension in VSCode.

Create Your First Dev Environment

We can now create our first Docker Desktop Dev Environment. To do that, open Docker Desktop and click on Dev Environments in the left navigation (Figure 2).

Figure 2: The Dev Environments is clearly still in beta but ready to use.

In the resulting window (Figure 3), click Run a single container.

Figure 3: Creating a sample Dev Environment in Docker Desktop.

In the popup window, click Get Started. You will then be prompted to give the Dev Environment a name. Leave everything else as is (Figure 4), and click Continue.

Figure 4: Naming your new Docker Dev Environment.

At this point, Docker Desktop will do its thing and pull everything necessary for the environment. You’ll see a list of images that are created and, when it’s complete, a Successful notification. When it’s finished, click Continue.

In the final screen (Figure 5), click Open in VSCode to open the new dev environment in your IDE.

Figure 5: Our sample Dev Environment has been created and is ready to work with.

Once VSCode opens the environment, you can start developing within that environment.

Or, you can go back to Docker Desktop, click the three-dot menu associated with the newly-created Dev Environment, and click Exec In CLI (Figure 6), which will drop you into a terminal window (within Docker Desktop) inside the running container, where you can work directly with whatever container you’ve used for your Dev Environment.

Figure 6: Accessing the CLI for the running container of our Dev Environment.

From that same window, you can view Logs and Stats for the running container, inspect the environment and mounts for the container, and view an expandable hierarchy of all directories and files within the container.

The container(s) within the Dev Environment will continue running until you stop them. To do so, go back to the environment listing, hover your cursor over the running container, and click the stop button (Figure 7).

Figure 7: Stopping a running container with the Dev Environment.

Stopping the container within the environment doesn’t delete the environment itself and you can add as many environments as you need.

And that’s the gist of creating your first Dev Environment with Docker Desktop. Keep in mind, Dev Environments is still in Beta, so it may be changed quite a bit yet before it is finalized. But even this early iteration shows great promise.

Next time we visit this topic, we’ll learn how to create Dev Environments with both local and remote repositories. Until then, keep poking around this new Docker Desktop feature, so you can see just how valuable a tool it could be to your teams.

Group Created with Sketch.