Sign inSign up

chusri/mysql-client-awscli

By chusri

โ€ขUpdated over 1 year ago

Alpine image with MySQL 5 client and AWS CLI for backups and automation tasks.

Image
Databases & storage
0

10K+

chusri/mysql-client-awscli repository overview

โ mysql-client-awscli:alpine-3.21

A minimal Docker image based on Alpine Linux 3.21 with:

  • ๐Ÿฌ MySQL 5 client (mysql)
  • โ˜๏ธ AWS CLI (aws)
  • ๐Ÿณ Lightweight footprint (~20MB)

Ideal for database dumps, backups to S3, and CLI-based workflows in CI/CD or Kubernetes CronJobs.


โ ๐Ÿงฐ Included Tools

ToolVersion
Alpine Linux3.21
MySQL Client5.x
AWS CLIv2.x

โ ๐Ÿš€ Usage

โ ๐Ÿ“ฅ Pull from DockerHub
docker pull chusri/mysql-client-awscli:alpine-3.21
โ ๐Ÿ› ๏ธ Example: MySQL Dump to S3
docker run --rm \
  -e AWS_ACCESS_KEY_ID=xxx \
  -e AWS_SECRET_ACCESS_KEY=yyy \
  chusri/mysql-client-awscli:alpine-3.21 \
  sh -c 'mysqldump -h your-db-host -u your-user -pYOUR_PASSWORD your_db \
  | gzip | aws s3 cp - s3://your-bucket/mysql-backup.sql.gz'
โ ๐Ÿข Kubernetes CronJob Example

You can use this image directly in a Kubernetes CronJob to backup your MySQL database to S3.

โฐ Runs daily at 2:00 AM
๐Ÿ’พ Dumps database โ†’ compresses with gzip โ†’ uploads to s3://your-s3-bucket/

โ ๐Ÿงฉ CronJob YAML
apiVersion: batch/v1
kind: CronJob
metadata:
  name: mysql-backup-job
spec:
  schedule: "0 2 * * *"  # Runs daily at 2:00 AM
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: backup
              image: chusri/mysql-client-awscli:alpine-3.21
              env:
                - name: MYSQL_HOST
                  value: "your-mysql-host"
                - name: MYSQL_USER
                  value: "your-username"
                - name: MYSQL_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: mysql-secret
                      key: password
                - name: AWS_ACCESS_KEY_ID
                  valueFrom:
                    secretKeyRef:
                      name: aws-secret
                      key: access_key
                - name: AWS_SECRET_ACCESS_KEY
                  valueFrom:
                    secretKeyRef:
                      name: aws-secret
                      key: secret_key
              args:
                - sh
                - -c
                - |
                  mysqldump -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD your_db \
                  | gzip \
                  | aws s3 cp - s3://your-s3-bucket/mysql-backup-$(date +\%F).sql.gz
          restartPolicy: OnFailure
โ ๐Ÿ” Secrets Example
apiVersion: v1
kind: Secret
metadata:
  name: mysql-secret
type: Opaque
stringData:
  password: your_mysql_password
---
apiVersion: v1
kind: Secret
metadata:
  name: aws-secret
type: Opaque
stringData:
  access_key: your_aws_access_key
  secret_key: your_aws_secret_key

โ ๐Ÿงช Build Locally

docker build -t chusri/mysql-client-awscli:alpine-3.21 .

โ ๐Ÿ“ License

This project is licensed under the MIT License. See the LICENSEโ  file for details.

Tag summary

Content type

Image

Digest

sha256:7a43ebf93โ€ฆ

Size

49.2 MB

Last updated

over 1 year ago

docker pull chusri/mysql-client-awscli