This post provides another basic docker-compose.yml .This time is to create a MySQL container with initial user accounts.
- Docker for Windows. Please install this before proceeding.
- MySQL 8. This is the version of MySQL that our Docker image has.
- Windows 10 64-bit
docker-compose.yml: A YAML File
When we use this to create a Docker container, the MySQL instance will have an initial user with turreta username. Moreover, it will enable the root user and create a database.
How to Use the docker-compose.yml For MySQL
Next, open a Windows Command Line prompt and cd to the directory where the docker-compose.yml file is. Then, run the following commands.
1. Pull the image from Docker Hub to the local machine.
To pull the image from Docker Hub, run the following command on the command-line window. If we look at our docker-compose.yml again, we see mysql:8. This means docker-compose will put an image of mysql:8 from Docker Hub.
2. Create and Run a MariaDB container
After pulling the image, we can now create a Docker container for our image. Although it took two steps to start up a container, we don’t have to do it all the time. We can use the following command to pull an image from Dock Hub and start a Docker container in one command.
docker-compose up demo-container-mysql-db
Once we successfully started the MySQL Docker container, we can already connect our applications to the database.
This post is part of the Docker For Developers tutorial.
Leave a reply →
docker-compose up demo-container-dbto
docker-compose up demo-container-mysql-db.
Comments are closed.