.NET 6 Docker container running on CentOS host throws a "Resource temporarily unavailable" when trying to connect to a dockerized postgres container

Viewed 21

I have two Dockerized .NET 6 APIs that are started using docker-compose along with the application front end and a postgres database (currently v14.5). Prior to upgrading to .NET 6 both of my .NET docker containers were able to connect to and interact with the Postgres database. After the upgrade both of my containers put themselves into a crash loop, continuously crashing and restarting.

I was finally able to attach a debugger to one of them and found that when I am calling the Npgsql.Migrate() function, it is returning with an ExtendedSocketException stating the "Resource is temporarily unavailable". Inside of this failing container I loaded up psql and connected to the database and was able to query data without any issues. I can ping from the .NET containers to the postgres container, and from the postgres container to the .NET containers without issue. However when the .NET process tries to access the container it continues to throw this ExtendedSocketExecption. I have disabled the firewall on the host and restarted but I'm still having this issue.

This compose file works fine on my MacBook and everything runs as expected until I deploy it to a CentOS host.

1 Answers

Turns out that having ASPNETCORE_URLS in a Docker Compose file causes this error. Most likely because I was telling .NET to host itself outside of my Docker network.

Related