Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot able to run a docker image on Linux Machine for dot net core 2.1 application which is using MySQL db with Pomelo.EntityFrameworkCore.MySql

Following exception is being thrown when .net core 2.1 API application's docker image is executed(run) on Linux machine

I am using Pomelo.EntityFrameworkCore.MySql to use MySQL Database

When I build and run the api image on windows machine it is running fine, but when I tried to run the same image on linux, following exception is being thrown.

It is the same case when I build and run the image on linux machine.

Not sure what is going wrong.

Microsoft.EntityFrameworkCore.Database.Connection[20004. An error occurred using the connection to database '' on server ''. MySql.Data.MySqlClient.MySqlException (0x80004005): Connect Timeout expired. --- System.ObjectDisposedException: Safe handle has been closed at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success) Interop.Sys.TryChangeSocketEventRegistration(IntPtr port, SafeHandle socket, SocketEvents currentEvents, SocketEvents newEvents, IntPtr data)

Looking forward for expert help and highly appreciated.

like image 804
suraj13k Avatar asked Nov 07 '22 02:11

suraj13k


1 Answers

The container/server running MySQL Server is not accessible from your Docker container running your application. As a result, your application is timing out (“Connect Timeout expired”) when attempting to open a database connection.

Make sure your network setup allows your web server to contact the DB server on port 3306.

like image 94
Bradley Grainger Avatar answered Nov 12 '22 09:11

Bradley Grainger