aspire icon indicating copy to clipboard operation
aspire copied to clipboard

Container port not exposed when using `WithVolume()`

Open silverxjohn opened this issue 1 year ago • 5 comments
trafficstars

I noticed that when I added .WithVolume(), the created container is not exposing the port.

Relevant code:

var postgresPassword = builder.AddParameter("postgresql-password", secret: true);

var postgres = builder.AddPostgres("postgres", password: postgresPassword, port: 63015)
    .WithVolume();

Without WithVolume()

Screenshot 2024-05-25 at 8 40 07 PM

With WithVolume()

Screenshot 2024-05-25 at 8 41 15 PM

silverxjohn avatar May 25 '24 12:05 silverxjohn

That code sample you pasted doesn't compile. WithVolume takes a required argument. Is that the code you are actually using?

image

davidfowl avatar May 25 '24 14:05 davidfowl

Sorry, I was actually using WithDataVolume() but I found similar issue from StackOverflow so I thought I'd change it to WithVolume() for this report.

silverxjohn avatar May 25 '24 15:05 silverxjohn

Everything seems to be working fine but the docker desktop UI does not show the ports. It doesn't seem to be related to using volumes either:

image

davidfowl avatar May 25 '24 15:05 davidfowl

That's weird. I've tried multiple times and it sometimes exposes the port other times not. Could just be a problem with my machine. Sorry to bother you. Thanks for taking the time looking into this.

silverxjohn avatar May 25 '24 15:05 silverxjohn

Could this be a variation of #4066? If the new postgres container tries to start up before the previous one has fully shut down, the port may be blocked by the old instance.

afscrome avatar May 26 '24 17:05 afscrome

This smells more like a Docker Desktop UX bug.

mitchdenny avatar Jun 04 '24 10:06 mitchdenny

Could this be a variation of #4066? If the new postgres container tries to start up before the previous one has fully shut down, the port may be blocked by the old instance.

If that were the case, the container would just fail to start, and not run without the port mapping. So I doubt this is related to #4066

karolz-ms avatar Jun 06 '24 21:06 karolz-ms

Looks like this is external to Docker Desktop. Going to close but if you run into an issue where Aspire is not binding the ports correctly, re-open this.

dbreshears avatar Jul 01 '24 18:07 dbreshears