If you work with Docker, the Docker Visual Studio Code extension from Microsoft is a good productivity tool.
To install the extension, launch Visual Code, click the "Extensions" button (Fig. 1) in the left toolbar and search for "Docker", as shown in Fig. 2.
Select the "Docker" extension published by Microsoft and click the [Install] button.
After installation completes, a "Docker" icon (Fig. 3) appears in the left toolbar.
Some of the features of this extension are:
- Color coding of Dockerfile syntax
- Intellisense in Dockerfile
- Display Docker objects
- Right-click for quick Docker actions
With the extension installed, you get syntax color coding of a Dockerfile, as shown in Fig. 4
Notice that the keywords are pink, literal strings are orange, and image repositories are green.
The extension also provides Intellisense for a Dockerfile. Press CTR+SPACE after a repository and see a list of tags within that repo, as shown in Fig. 5.
Right-click the Dockerfile within the Explorer to display a context menu. With this extension installed, the menu will include an option to "Build image…" as shown in Fig. 6.
Select this option to build an image based on this Dockerfile. This will prompt you for an image name, as shown in Fig. 7, and execute the "build image" command in the terminal window with the appropriate arguments.
The "Docker" tab of the left menu displays a list of containers, images, registries, networks, and volumes.
Right-click an image to display a context menu. Select the "Inspect" option, as shown in Fig. 8 to output JSON about that image, as shown in Fig. 9.
Select "Run" from the Image context menu to build a container based on this image, as shown in Fig. 10.
This will execute the "build run" command in the Terminal window with the appropriate arguments. Any local containers will display in the "Docker" tab, as shown in Fig. 11.
You can right-click a container to display a context menu, as shown in Fig. 12.
From this menu, you can inspect the properties of the container, view logs, or open the default port in a web browser.
The Visual Studio Code Docker extension from Microsoft provides some helpful features to make your experience working with containers more productive.