DEV Community

Sarvesh
Sarvesh

Posted on • Edited 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/


πŸ‘‹ Connect with Me

Thanks for reading! If you found this post helpful or want to discuss similar topics in full stack development, feel free to connect or reach out:

πŸ”— LinkedIn: https://www.linkedin.com/in/sarvesh-sp/

🌐 Portfolio: https://sarveshsp.netlify.app/

πŸ“¨ Email: sarveshsp@duck.com

Found this article useful? Consider sharing it with your network and following me for more in-depth technical content on Node.js, performance optimization, and full-stack development best practices.

Top comments (0)