Would you like to learn how to install MySQL using Docker on Ubuntu Linux? In this tutorial, we are going to show you all the steps required to perform the MySQL installation using Docker on a computer running Ubuntu Linux in 5 minutes or less.
• Ubuntu 20.04
• Ubuntu 19.04
• Ubuntu 18.04
• MySQL 8.0.21
Equipment list
The following section presents the list of equipment used to create this tutorial.
As an Amazon Associate, I earn from qualifying purchases.
Related tutorial – MySQL
On this page, we offer quick access to a list of tutorials related to MySQL.
Tutorial MySQL – Docker Installation on Ubuntu Linux
Install the Docker service.
Download the MySQL docker image from the online repository.
List the Docker images installed on your system.
Here is the command output:
Start a new MySQL container using this Docker image.
Here is the command output:
In our example, the Docker image was used to start a new container.
The new container is using the local port 3306.
The container ID is e4a4aa78c2082dbc6e7d52953b8947aa2ac0f070d418f94d13ee8c24c26a95a3.
The MySQL password configured was kamisama123.
Congratulations! You have finished the MySQL Docker installation on Ubuntu Linux.
Docker MySQL – Persistent data
Create the required directory to store the MySQL data.
Start a MySQL container with persistent data storage.
In our example, the MySQL password configured was kamisama123.
Verify the content of the persistent data directory.
Congratulations! You successfully configured the use of Docker persistent data storage.
Tutorial MySQL – Testing the Docker installation
Install the MySQL client package on the localhost.
Access the MySQL service running on the Docker container.
Here is the command output:
Congratulations! Your MySQL Docker installation was tested successfully.
Tutorial MySQL – Docker container management
Verify the status of all Docker conteiners using the following command:
Here is the command output:
Verify the status of the MySQL container using the ID or its name.
Here is the command output:
To stop the MySQL container service, use the following command:
To start the MySQL container service, use the following command:
To restart the MySQL container service, use the following command:
In case of error, use the following command to verify the MySQL container logs.
In our examples, we demonstrated how to manage the MySQL container using its ID or the name previously defined.