DEV Community

crit3cal
crit3cal

Posted on

Fire Up your mysql in a Docker Container 🔥🔥

Docker must be installed, before following these steps.

3 min Step...

  1. Setup volume to persist the data

    docker volume create mysql-volume

  2. Docker Run

    docker run --name deep -p 3307:3306 -v mysql-volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql

  3. List the running containers

    docker ps

  4. Container shell access

    docker exec -it deep mysql -u root -p

Some of the docker terminologies used

--name : name of the container.
-p : port forwarding , default mysql port is 3306
-v : setup volume to persist the data for the container.
-e : provide an environment variable.
-d : start the container in detached mode.

Please note that you have to give the same password we have defined to run the container (root)

For more, refer the mysql docker hub docs
https://hub.docker.com/_/mysql/

Top comments (0)