Skip to content

Tutorial of a Simple ASP.NET Core Web Api running in Docker Desktop for Windows 10 Home

Notifications You must be signed in to change notification settings

yeasin90/aspnetcore-simple-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Running an ASP.NET Core Web Api with Docker Desktop.

  1. For Windows 10 Home, OS build must be 1903 or higher. Noe that Windows container is not supported for Windows 10 Home. You will only be able to use Linux Container from Docker Desktop and cannot switch to Windows container.

container-swich-grayed-out

Why? check this : docker/for-win#9701 (comment)

  1. Install latest docker desktop (if not installed) : https://docs.docker.com/docker-for-windows/install-windows-home/?fbclid=IwAR3LWY5cZ3agrtom1fFhMxQSGTttImiaMRNDDei6UrNQwMK7BAsw6ZOAndU

  2. Create a simple ASP.NET Core Web Api project from Visual Studio 2019 (Leave the docker support option.)

  3. To run your app into docker, first you need to build a Docker Image with your app. And then this image needs to run inside docker container :

4.1 Add Docker support to your project (There will be an OS option to choose. Select Linux - because Windows 10 Home does not support Windows Docker) :

add-docker-support

4.2 From Visual Studio, select Tools->Command Line->Developer Command prompt

4.3 Build a docker image for your project with below command = docker build -f Dockerfile -t mydockertrial:development .. (microsoft/DockerTools#167)

here, [mydockertrial] = docker image name, user defined. [developerment] = tag name, user defined.

After this command is executed, you will see your image in Docker Desktop images panel :

my-docker-image

4.4 Run this image in Docker Container with command : docker run -p 1234:80 --name testdockercontainer mydockertrial:development

here, [testdockercontainer] = my docker container name, user defined.

You will see your container in Docker Desktop container panel :

my-docker-container

  1. Our docker image is ready and running in Dokcer Container. It means we should be able to see : http://localhost:1234/swagger/index.html, but there is no response

no-response

  1. To fix it :
  • Comment out the if condition (line#40) from Startup.cs

strtpu

working-swagger

About

Tutorial of a Simple ASP.NET Core Web Api running in Docker Desktop for Windows 10 Home

Topics

Resources

Stars

Watchers

Forks