Solution

How to install MySQL 5.7 with Docker

Run an older MySQL 5.7 version with predictable mounted directories and generated credentials on a modern Docker host.

Updated 2026-03-26

Problem statement

How do I run MySQL 5.7 safely on a newer Docker host?

The key is to isolate the older database into a dedicated container, bind a stable data directory, and make the generated credentials and host paths explicit for operations handoff.

A scripted install is especially useful here because MySQL 5.7 is still common in legacy applications, but ad-hoc docker run commands are harder to reproduce later.

What to check

  • Keep data, config, and init SQL in separate host paths.
  • Print connection details at the end of install.
  • Treat the generated root password as a handoff artifact.

Parent topic

Maintain older application stacks such as PHP 7.2 and Workerman on Docker while keeping deployment steps standardized enough for handoff and recovery.