This is aguest post from Jochen Zehnder. Jochen is a Docker Community Leader and workingas a Site Reliability Engineer for 56K.Cloud. He started his career as aSoftware Developer, where he learned the ins and outs of creating software. Heis not only focused on development but also on the automation to bridge the gapto the operations side. At 56K.Cloud he helps companies to adapt technologiesand concepts like Cloud, Containers, and DevOps. 56K.Cloudis a Technology company from Switzerland focusing on Automation, IoT,Containerization, and DevOps.
Docker visual-studio-code ide docker-container. Improve this question. Follow asked Nov 14 '18 at 3:05. Curtank curtank. 330 1 1 gold badge 3 3 silver badges 12 12 bronze badges. The only thing i need is to edit, no debug request involved. – curtank Nov 14 '18 at 3:07. The Visual Studio Code Remote - Containers extension lets you use a Docker container as a full-featured development environment. It allows you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set.
Jochen Zehnder joined 56K.Cloud inFebruary, after working as a software developer for several years. He always triesto make the lives easier for everybody involved in the development process. OneVS Code feature that excels at this is the Visual Studio Code Remote –Containers extension. It is one of many extensions of the Visual Studio RemoteDevelopment feature.
This postis based on the work Jochen did for the 56K.Cloud internal handbook. It uses Jekyll to generate a static website out ofmarkdown files. This is a perfect example of how to make lives easier foreverybody. Nobody should know how to install, configure, … Jekyll to makechanges to the handbook. With the Remote Development feature, you addall the configurations and customizations to the version control system of yourproject. This means a small group implements it, and the whole team benefits.
One thing Ineed to mention is that as of now, this feature is still in preview. However, Inever ran into any issues while using it, and I hope that it will get out ofpreview soon.
Prerequisites
You need tofulfil the following prerequisites, to use this feature:

- Install Docker and Docker Compose
- Install Visual Studio Code
- Install the Remote – Container extension
Enable it for an existing folder
The Remote– Container extension provides several ways to develop in a container. Youcan find more information in the documentation,with several Quick start sections. In this post, I will focus on how toenable this feature for an existing local folder.
As with allthe other VS Code extensions, you also manage this with the Command Palette.You can either use the shortcut or the green button in the bottom left cornerto open it. In the popup, search for Remote-Containers and select OpenFolder in Container…
In the nextpopup, you have to select the folder which you want to open in the container.For this folder, you then need to Add the Development ContainerConfiguration Files. VS Code shows you a list with predefined containerconfigurations. In my case, I selected the Jekyll configuration. Afterthat, VS Code starts building the container image and opens the folder in thecontainer.
If you now have a look at the Explorer you can see, that there is a new folder called `.devcontainer`. In my case, it added two files. The `Dockerfile` contains all the instructions to build the container image. The `devcontainer.json` contains all the needed runtime configurations. Some of the predefined containers will add more files. For example, in the `.vscode` folder to add useful Tasks. You can have a look at the GitHub Repo to find out more about the existing configurations. There you can also find information about how to use the provided template to write your own.
Customizations
Thepredefined container definitions provide a basic configuration, but you cancustomize them. Making these adjustments is easy and I explain the two changesI had to do below. The first was to install extra packages in the operatingsystem. To do so, I added the instructions to the `Dockerfile`. The secondchange was to configure the port mappings. In the `devcontainer.json`, Iuncommented the `forwardPorts` attribute and added the needed ports. Be aware,for some changes you just need to restart the container. Whereas for others,you need to rebuild the container image.
Using and sharing
After youopened the folder in the container you can keep on working as you are used to.Even the terminal connects to the shell in the container. Whenever you open anew terminal, it will set the working directory to the folder you opened in thecontainer. In my case, it allows me to type in the Jekyll commands to build andserve the site.
After Imade all the configurations and customizations, I committed and pushed the newfiles to the git repository. This made them available to my colleagues, andthey can benefit from my work.
Summary
VisualStudio Code supports multiple ways to do remote development. The VisualStudio Code Remote – Containers extension allows you to develop inside acontainer. The configuration and customizations are all part of your code. Youcan add them to the version control system and share them with everybodyworking on the project.
More Information
For moreinformation about the topic you can head over to the following links:
The Remote Container extension uses Docker as the container runtime.There is also a Docker extension, called: Docker for Visual Studio Code. Briangave a very good introduction at DockerCon LIVE 2020. The recording of his talk Become aDocker Power User With Microsoft Visual Studio Code isavailable online.
Find out more about 56K.Cloud
We love Cloud, IoT, Containers, DevOps, and Infrastructure as Code. If you are interested in chatting connect with us on Twitter or drop us an email: info@56K.Cloud. We hope you found this article helpful. If there is anything you would like to contribute or you have questions, please let us know!
This post originally appeared here.
Estimated reading time: 4 minutes
Introduction
This example demonstrates how to dockerize an ASP.NET Core application.

Why build ASP.NET Core?
- Develop and run your ASP.NET Core apps cross-platform on Windows, MacOS, andLinux
- Great for modern cloud-based apps, such as web apps, IoT apps, and mobilebackends
- ASP.NET Core apps can run on .NET Coreor on the full .NET Framework
- Designed to provide an optimized development framework for apps that aredeployed to the cloud or run on-premises
- Modular components with minimal overhead retain flexibility whileconstructing your solutions
Prerequisites
This example assumes you already have an ASP.NET Core appon your machine. If you are new to ASP.NET you can follow asimple tutorial to initialize a project orclone our ASP.NET Docker Sample.
Create a Dockerfile for an ASP.NET Core application
Method 1:
- Create a
Dockerfile
in your project folder. - Add the text below to your
Dockerfile
for either Linux orWindows Containers.The tags below are multi-arch meaning they pull either Windows orLinux containers depending on what mode is set inDocker Desktop for Windows. Read more onswitching containers. - The
Dockerfile
assumes that your application is calledaspnetapp
. Change theDockerfile
to use the DLL file of your project.
- To make your build context as small as possible add a
.dockerignore
file to your project folder and copy the following into it.
Method 2 (build app outside Docker container):
- Create a
Dockerfile
in your project folder. - Add the text below to your
Dockerfile
for either Linux orWindows Containers.The tags below are multi-arch meaning they pull either Windows orLinux containers depending on what mode is set inDocker Desktop for Windows. Read more onswitching containers. The
Dockerfile
assumes that your application is calledaspnetapp
. Change theDockerfile
to use the DLL file of your project. This method assumes that your project is already built and it copies the build artifacts from the publish folder. Refer to the Microsoft documentation on Containerize a .Net Core app.The
docker build
step here will be much faster than method 1, as all the artifacts are built outside of thedocker build
step and the size of the base image is much smaller compared to the build base image.This method is preferred for CI tools like Jenkins, Azure DevOps, GitLab CI, etc. as you can use the same artifacts in multiple deployment models if Docker isn’t the only deployment model being used. Additionally, you’ll be able to run unit tests and publish code coverage reports, or use custom plugins on the artifacts built by the CI.
- To make your build context as small as possible add a
.dockerignore
file to your project folder.
Build and run the Docker image
- Open a command prompt and navigate to your project folder.
- Use the following commands to build and run your Docker image:
View the web page running from a container
Visual Studio Code Docker Container
- Go to localhost:8080 to access your app in a web browser.
- If you are using the Nano Windows Containerand have not updated to the Windows Creator Update there is a bug affecting howWindows 10 talks to Containers via “NAT”(Network Address Translation). You must hit the IP of the containerdirectly. You can get the IP address of your container with the followingsteps:
- Run
docker inspect -f '{{ .NetworkSettings.Networks.nat.IPAddress }}' myapp
- Copy the container IP address and paste into your browser.(For example,
172.16.240.197
)
- Run
Further reading
Visual Studio Code Docker Debug
dockerize, dockerizing, dotnet, .NET, Core, article, example, platform, installation, containers, images, image, dockerfile, build, asp.net, asp.net core