Cloud Native 7 min read

Building and Sharing a Docker Image for mysqldiff on CentOS

This guide explains how to resolve database schema differences by creating a Docker image that packages mysqldiff on CentOS, detailing installation, image creation via both docker commit and Dockerfile, and publishing the image to Docker Hub for easy reuse.

转转QA
转转QA
转转QA
Building and Sharing a Docker Image for mysqldiff on CentOS

Background: During testing, a missing column error appears because the production database schema differs from the test database, prompting the need to compare online and offline databases.

The solution is to package mysqldiff in a Docker image, allowing consistent schema comparison across environments and simplifying distribution.

Docker Advantages

Docker can provide any required OS version instantly from a public registry.

Sharing the mysqldiff image eliminates environment‑specific installation issues for others.

Publishing to Docker Hub makes the tool globally accessible.

Step 1: Install and start Docker

Install Docker on CentOS 7 (minimum OS requirement) with yum install docker docker-devel -y and start it using service docker start (or restart with service docker restart).

Step 2: Build the image (docker commit method)

Create a container: docker run -it --name -vmysqldiff centos /bin/bash Optionally sync local files into the container with -v /zhaolixin/mysqldiff:/zhaolixin/mysqldiff.

Install the required RPMs inside the container:

rpm -ivh mysql-connector-python-2.1.6-1.el7.x86_64.rpm
rpm -ivh mysql-utilities-1.6.5-1.el7.noarch.rpm

Exit the container and commit the image: docker commit mysqldiff zhaolixin/mysqldiff Optionally add a message and author:

docker commit -m "first commit" -a "zhaolixin" mysqldiff zhaolixin/mysqldiff:v0.0.1

Verify the new image with docker images zhaolixin/mysqldiff.

Step 3: Test the image

Run the image: docker run -it zhaolixin/mysqldiff:v0.0.1 /bin/bash Execute mysqldiff to confirm it works (it prints usage information).

Step 4: Push the image to Docker Hub

Log in with docker login, then push: docker push zhaolixin/mysqldiff:v0.0.1 After pushing, the image can be seen in the Docker Hub repository.

Step 5: Build the image with a Dockerfile (recommended)

Create a Dockerfile in /zhaolixin/mysqldiff with the following content:

FROM centos:7
MAINTAINER 赵力新 "[email protected]"
RUN yum -y install wget \
    && wget https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.6-1.el7.x86_64.rpm \
    && wget https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.6.5-1.el7.noarch.rpm \
    && yum -y localinstall mysql-connector-python-2.1.6-1.el7.x86_64.rpm \
    && yum -y localinstall mysql-utilities-1.6.5-1.el7.noarch.rpm \
    && rm -f mysql-connector-python-2.1.6-1.el7.x86_64.rpm \
    && rm -f mysql-utilities-1.6.5-1.el7.noarch.rpm

Build and tag the image: docker build -t zhaolixin/mysqldiff:v0.0.2 . Check the image with docker images and use the same run and push steps as before.

Conclusion

The Dockerized mysqldiff image is now available for easy deployment and will later be turned into a micro‑service integrated with a testing platform for broader use.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockercontainerizationCentOSdatabase-diffmysqldiff
转转QA
Written by

转转QA

In the era of knowledge sharing, discover 转转QA from a new perspective.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.