Docker + Visual Studio – resolving error – Publish has encountered an error. Docker support must be enabled in the project

Background / Scenario :
- We have our docker team developing containerised applications (docker images)
- Our docker team needs to be push those respective docker images to our private registry (I am covering Docker Registry concepts in detail in upcoming articles)
- So got an opportunity to demonstrate how to push our application / docker image to our private registry from Visual Studio
- While publishing my application to our private registry from Visual Studio got below error
Error / Issue :
Publish has encountered an error.
Docker support must be enabled in the project. See https://aka.ms/vs-add-docker for information on adding Docker support to the project.

Details :
- I am using my Visual Studio 22 preview – community edition
- I have created simple one .NET Core console application to demonstrate as

- We want to publish this application to our private docker container registry
- So in “Solution Explorer” right click on project and “Publish” as

- On click on of “Publish” we will get an “Publish” dialog and various options to publish as
- Select the target – “Docker Container Registry” and click on “Next” button on the bottom of “Publish” dialog
- Then we need to select the – “Specific target” as shown in below fig
- Here we will select an option – “Other Docker Container Registry” option
- Click on “Next” button, we will have an option for our private registry URL and image tag
- Please specify the URL of registry and image tag
- Once we specified respective details, please click on “Publish” button as

Solution :
- By default Docker support is not added to Visual Studio project
- We need to explicitly add the docker support to our Visual Studio project
Steps to add Docker support the Visual Studio project :
- In Visual Studio , Solution Explorer, right click on project and click on “Add” as

- From “Add” option select option – “Docker Support” as
- As we click on “Docker Support…” option we will get an “Docker File Options” to select the our OS as
- As we select our OS, “DockerFile” is added to our project as (I’ll explain in detail about DockerFile in separate article)

- Now please try to publish and project will published to our private contained registry successfully 🙂
We have very good articles for Docker and Kubernetes please have a look once – https://knowledge-junction.in/category/containerization/
Thanks for reading 🙂 If its worth for you , kindly please Like and Share
HAVE a GREAT TIME AHEAD 🙂
You must log in to post a comment.