Please help me to conect mysql database to docker

I have my image processing codes in Docker containers. my database is MySQL database now the client sends the image through rest API to the database. now I want to connect the database to Docker containers so that the images sent by the client are sent to those containers and get processed. and the response generated is sent to the database back.

Could someone please explain me the procedure to connect the docker to the database.

You could create both containers on the same overlay network. Then the app container could talk with mysql. See docker connect a service to the overlay network.

Another thing you need to consider is mysql data persistence. When mysql container moves to another node, it should be able to read the existing data. You may refer to the discussions in the question: Data(base) persistence in docker swarm mode.