Deploying a MySQL Container Using the Portainer Application Image
Application Scenario
Portainer is a graphical tool for Docker management. It offers a range of functions such as status display, quick deployment of application templates, basic operations on Docker (containers, images, networks, and database logical volumes), log display, container console operations, centralized management and operations of Swarm clusters and services, and user login management and control. Supported By FlexusL, the Portainer application image uses Ubuntu 22.04 and is deployed using Docker. The Docker and Portainer have been preconfigured in the image. You can use this application image to visualize Docker management.
Resource Planning and Costs
Resource |
Configuration |
Description |
---|---|---|
Cloud server |
|
Select appropriate instance specifications based on your service requirements. |
Image |
Portainer |
Select the Portainer application image. |
Security group |
Inbound rule:
|
|
Process
Procedure |
Description |
---|---|
Purchase a FlexusL instance and select the Portainer application image. |
|
Add inbound security group rules to ensure that the application preinstalled in the image can be accessed. |
|
Log in to the dashboard and install and initialize Portainer. |
|
Use Portainer to visualize Docker management (using MySQL container as an example) |
Step 1: Purchase a FlexusL Instance
- Log in to the FlexusLconsole and click Buy FlexusL.
- Specify required parameters for the FlexusL instance.
Parameter
Example
Description
Region
CN-Hong Kong
For low network latency and quick resource access, select the region nearest to your target users. After a FlexusL instance is created, the region cannot be changed. Exercise caution when selecting a region.
Application Images
Portainer
Select the Portainer application image.
Instance Specifications
2 vCPUs | 4 GiB memory and 80 GiB system disk
Select instance specifications as needed.
Instance Name
Portainer-Example
Customize an instance name that is easy to identify, for example, Portainer-Example.
(Optional) Associated Services
- Data disk: 10 GiB
- Host security
- Cloud backup vault: 90 GiB
You can bundle any of the services to your FlexusL instances as needed: EVS, HSS (basic edition), and CBR and set specifications as needed.
Required Duration
1 month
The minimum duration of a purchase is one month and the maximum duration is three years.
Auto-renew is enabled by default, which means the purchased FlexusL instances will be automatically renewed before they expire. If you do not enable auto-renew during the purchase process, you can still enable it later after the instances are created. For more information about auto-renewal rules, see Auto-Renewal Rules.
Quantity
1
Set the number of FlexusL instances to be purchased.
- Click Buy Now and complete the payment as prompted.
- Go back to the FlexusL console and view the purchased FlexusL instance.
After a FlexusL instance is created using an application image, wait until the image with the pre-installed application is up and running. Then, you can perform operations such as restarting or stopping the instance, or resetting the password. Otherwise, the installation may fail and you cannot log in to the image application dashboard.
Step 2: Configure Security Groups
Add inbound security group rules to ensure that the application preinstalled in the image can be accessed.
- Log in to the FlexusL console and click a resource card to go to the instance details page.
- In the navigation pane on the left, choose Cloud Servers. Locate the server and click its name.
- On the Security Groups tab, click Add Rule. In the displayed dialog box, add rules displayed in the following figure and click OK.
The following figure only displays common rules. You can add more rules as needed.
Table 1 Security group rules Priority
Action
Type
Protocol & Port
Source
Description
1
Allow
IPv4
TCP: 80
0.0.0.0/0
Specifies the internal forwarding port of application images
1
Allow
IPv4
TCP: 3306
0.0.0.0/0
Allows access to MySQL databases.
1
Allow
IPv4
TCP: 9001
0.0.0.0/0
Allows external access to the application dashboard.
Step 3: Initialize Portainer
The image application dashboard needs to be initialized only when you log in for the first time.
- On the Overview page, click Access in the Dashboard field in the Image area.
If the dashboard of WordPress cannot be accessed, it may be because the port for accessing the dashboard is not allowed or the application has not been up and running. To solve this problem, see Why Can't I Open the Dashboard of the Application Pre-installed in the Application Image?
If you use a Portainer application image to create, reinstall, or change the OS of a FlexusL instance, Portainer initialization has a certain validity period. If no users are created within the validity period, a message in the following figure is displayed. In this case, log in to the server and run sudo docker restart portainer to restart Portainer, and then create a user as soon as possible.
- Set the username and password of the Portainer administrator and click Create user.
If you have backup data for Portainer, click Restore Portainer from backup and upload the backup data to quickly set up the Portainer environment.
- Choose Home and click local to use Portainer for Docker visual management.
Then, you have obtained a Portainer hosting server. You can start using Portainer or follow the instructions provided in Step 4: Use Portainer to Deploy a MySQL Container to create and connect to a MySQL container.
Step 4: Use 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.
- 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.
- 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