Using Portainer to Deploy a MySQL Container
This section uses the MySQL container as an example to describe how to use Portainer to visualize Docker management.
Creating a MySQL Container
- Choose Containers in the left navigation pane and click Add container.
- Specify MySQL container parameters.
- ① Name: user-defined container name.
- ② Image: container image name. For example, if you set this parameter to mysql:5.7, the system automatically pulls the MySQL5.7 container image from Docker Hub.
- ③ Click publish a new network port and add port 3306 to ensure that the MySQL database can be accessed.
- ④ Env: environment variables.
- MYSQL_ROOT_PASSWORD: password of the root user of the database. This parameter is mandatory. It is used for logging in to the MySQL container. Keep the password secure.
Ensure that the MYSQL_ROOT_PASSWORD parameter name is correctly entered, or the database cannot be connected.
- MYSQL_DATABASE: name (such as wordpress) of the database which is automatically created in the value row after the MySQL container is created. This parameter is optional.
- MYSQL_ROOT_PASSWORD: password of the root user of the database. This parameter is mandatory. It is used for logging in to the MySQL container. Keep the password secure.
- ⑤ Restart policy: You are advised to select Always so that the container is always automatically restarted when it is stopped.
- Click Deploy the container to create a MySQL container.
Connecting to the MySQL Container
- Return to the container list and click in the MySQL container row.
- On the displayed page, click Connect to connect to the container.
- Run the following command to log in to the MySQL database:
mysql -uroot –p123456, in which 123456 is the value of MYSQL_ROOT_PASSWORD.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot