❔ Docker and Visual Studio - ASP.NET Core projects
Hello. I've recently been assigned the task to split a very big Web Service into smaller services, so that I can containerize them and orchestrate them with K8s. I've successfully split them and now what I have is a solution, and each project in that solution Is a Web Service that does a specific task.
I've been experimenting with Docker and Visual Studio a bit, read some documentation, and gathered some questions that hopefully someone could help me understand better.
So the first question is about how I should organize the projects. My main concert is that, if there is going to be any problem with having a single repository in Git that contains the solution and all the projects inside, of if I should split them by solutions and have one repository for each. I understand that when I have the whole thing running, if I want to change the code of a service I only need a Docker Image so that K8s can deploy newer versions, but maybe someone knows better and how I currently have things organized could be an issue.
The second question is, I'm having trouble interacting with the services without them being run using Visual Studio. If I manually build a Docker Image (using the Dockerfile the Visual Studio generated), and then create and run a container using that image I created, yes it runs but I'm never able to interact with the service. When I run the
docker ps
or docker containers ls --all
command, and put 2 containers running side by side, one that I created and the other created by Visual Studio in either Debug or Release mode, The ones VS creates in the PORT
column get mapped to a port on my local machine, where the one I created only shows the ports the container has exposed (80 and 443 in my case). So this is something I don't yet understand why is happening or how can I talk with the container.
Third question is regarding the containers Visual Studio creates.8 Replies
a single repository in Git that contains the solution and all the projects insidePerfectly fine.
manually runningYou'll need to pass port mappings when you run it. VS does that for you.
When I use Visual Studio to make a container, I'm pretty confident it's not using the Dockerfile It generated for my project. I say this because, first of all if I'm in Debug, it adds a bunch of extra stuff to the image, and also the resulting image name gets a
:dev
tag. And second, the container starts with a different command then the one I specify in the Dockerfile. I'm currently using Linux containers, and the containers Visual Studio starts all run the infinite wait command, Visual Studio itself tell the container after it's running what to do with a docker exec
command. Also, these images Visual Studio creates I suspect they are immediately deleted or maybe not managed by Docker at all, since listing the images with docker images
command does not show them. Can someone confirm this?
I see, port mapping, but I don't want to have that in the Dockerfile, correct, it's a flag in the docker run
command?yup
I will look into that, thanks for pointing that out.
--publish , -p Publish a container’s port(s) to the hosthttps://docs.docker.com/engine/reference/commandline/run/#publish
I see, thank you for sharing!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.