Set Up MySQL with Docker

Learn how to set up MySQL database in the local environment with a Docker container.

MySQL Docker container

MySQL is one of the most popular open-source relational database management systems. We use it to persist data in this course.

While the examples in this course are accessible without local installations, if we need to set up the local environment, this guide will help us to use a Docker container to set up a local MySQL database.

Using a Docker container makes installation easier and keeps the database separate, avoiding conflicts and making maintenance easier.

Configure the MySQL Docker container

Before starting the setup, we must install the Docker Desktop by following the instructions in the set up a local development environment lesson of the “Appendix” chapter.

Follow the steps below to pull and run a MySQL Docker container. Here, we use a Ubuntu-based MySQL Docker container as an example. If you use a different operating system, the steps should be similar.

Pull the MySQL Docker image

First, start the Docker Desktop, open a terminal, and execute the following command to pull the Ubuntu MySQL Docker image from Docker Hub:

Get hands-on with 1400+ tech skills courses.