Rate This Document
Findability
Accuracy
Completeness
Readability

(Method 2) Using Docker to Build a MySQL Docker Image

Installing Docker

For details about how to install Docker, see Docker Installation Guide.

Installing the MySQL Database

For details about how to install the MySQL database on the physical machine, see Installing MySQL on a Physical Machine. You are advised to install the MySQL database by compiling the source code.

Creating a MySQL Docker Image

Run the supermin5 command to build a Docker image of the OS. The following uses the custom image openeuler-20.03-sp1-aarch64 as an example. The yum, net-tools, initscripts, and vi commands are pre-installed in the image. After the build is complete, submit the image.

  • /usr/local/mysql in 4 is the MySQL installation package compiled in 5.3. Replace it with the actual path of the installation package.
  • openeuler-20.03-sp1-aarch64.tar is the TAR image package in 5. Replace it with the actual package name.
  • openeuler-20.03-sp1-aarch64 is the image name in 6. Replace it with the actual image name.
  1. Install the supermin tool.
    1
    yum install supermin* -y
    
  2. Prepare the software package to be installed and save it in the supermin.d directory.
    • CentOS
      1
      2
      yum install net-tools
      supermin5 -v --prepare bash yum net-tools initscripts vi coreutils -o supermin.d
      
    • openEuler
      1
      supermin -v --prepare bash yum net-tools initscripts vi coreutils -o supermin.d
      
  3. Create an image and save it in the appliance.d directory.
    • CentOS
      1
      supermin5 -v --build --format chroot supermin.d -o appliance.d
      
    • openEuler
      1
      supermin -v --build --format chroot supermin.d -o appliance.d
      
  4. Copy the MySQL installation package compiled in Installing the MySQL Database.
    1
    cp -r /usr/local/mysql appliance.d/usr/local/
    
  5. Build the image.
    1
    tar --numeric-owner -cpf openeuler-20.03-sp1-aarch64.tar -C appliance.d/ .
    
  6. Import the image to the container.
    1
    cat openeuler-20.03-sp1-aarch64.tar | docker import - openeuler-20.03-sp1-aarch64
    
  7. Run the Docker command to view the image.
    1
    docker images | grep openeuler-20.03-sp1-aarch64
    

Starting the MySQL Docker Container

  1. Run a container instance by using the image. Create a container and run it in the background.
    1
    docker run -itd --name mysql openeuler-20.03-sp1-aarch64 bash
    
  2. View the running container.
    1
    docker ps
    
  3. Log in to the container.
    1
    docker exec -it mysql bash