This is a deep repo where we learn about docker container and docker network and how to connect them
step 1: docker build -t . make images
step 2: docker run -d --name mysql-db - e MYSQL_ROOT_PASSWORD=falana mysql docker run -d --name app -e MYSQL_HOST=mysql-db (name of the container you build previously) -e MYSQL_USER=anyname -e MYSQL_PASSWORD=0000 -e MYSQL_DB=backend (the database where you wannt to save data) :tag (genrally latest)
make network // don't make directly container without network cuz then you need to make new one container -> make network docker network create docker network connect docker inspect docker network disconnect
-- but ensure to run both the containers
// or you can do as docker run -d --name app --network -e MYSQL_HOST=mysql-db (name of the container you build previously) -e MYSQL_USER=anyname -e MYSQL_PASSWORD=0000 -e MYSQL_DB=backend (the database where you wannt to save data) :tag (genrally latest) //if you previously have any network but the above method is more convinent
step 3: docker bind the volume(data storied in the container) with the computer disk so that the data shouldn't lost if anything happen //not your hard drive but the cloud where your database will be stored