Docker MySQL integration¶
The Docker MySQL integration allows developers to run a MySQL database within a Docker container, enabling a lightweight, portable, and isolated database environment^[600-developer-docker-index.md].
Deployment¶
To run MySQL, the standard Docker command can be used to pull and execute the official image^[600-developer-docker-index.md].
docker run --name mysql-db -e MYSQL_ROOT_PASSWORD=password -d mysql
Network Configuration¶
By default, the containerized MySQL instance is isolated. To allow the host machine or other containers to access the database, port mapping is required.^[600-developer-docker-index.md] This forwards traffic from a specific port on the host to the MySQL default port (3306) inside the container^[600-developer-docker-index.md].
Port Mapping Example:
docker run --name mysql-db -p 33060:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql
-p 33060:3306: Maps host port33060to container port3306^[600-developer-docker-index.md].
Related Concepts¶
- [[Docker]]
- [[Docker networking]]
Sources¶
^[600-developer-docker-index.md]