Sign inSign up

snickerjp/docker-mysql-shell

By snickerjp

•Updated 1 day ago

dockernize MySQL Shell

Image
0

3.0K

snickerjp/docker-mysql-shell repository overview

⁠Docker MySQL Shell

Build Test Build and Push

A minimal Docker image for MySQL Shell, based on Debian 13 (slim).

⁠Available Tags

  • snickerjp/docker-mysql-shell:26.10.0 — Full version (pinned)
  • snickerjp/docker-mysql-shell:9.7 — Minor version (rolling update)
  • snickerjp/docker-mysql-shell:Innovation — Innovation series (rolling update)
  • snickerjp/docker-mysql-shell:latest — Latest version
⁠Deprecated Tags

The following tags are deprecated and will no longer be updated:

  • 8.4, LTS — Former LTS Series
  • 9.6 — Former Innovation Series

⁠Quick Start

# Run in interactive mode
docker run -it --rm snickerjp/docker-mysql-shell:latest

# Connect to MySQL Server (Classic Protocol)
docker run -it --rm snickerjp/docker-mysql-shell:latest \
  --uri mysql://user:pass@host:3306/schema

# Connect to MySQL Server (X Protocol)
docker run -it --rm snickerjp/docker-mysql-shell:latest \
  --uri mysqlx://user:pass@host:33060/schema

⁠Usage Examples

⁠Connect in SQL mode
docker run -it --rm snickerjp/docker-mysql-shell:latest \
  --sql --uri mysql://root@host:3306
⁠Start in JavaScript mode
docker run -it --rm snickerjp/docker-mysql-shell:latest --js
⁠Start in Python mode
docker run -it --rm snickerjp/docker-mysql-shell:latest --py
⁠Execute a SQL file
docker run -i --rm \
  -v ./queries:/queries \
  snickerjp/docker-mysql-shell:latest \
  --sql --uri mysql://root@host:3306 -f /queries/setup.sql
⁠Check InnoDB Cluster status
docker run -it --rm snickerjp/docker-mysql-shell:latest \
  --uri mysql://admin@host:3306 \
  -- cluster status
⁠Docker Compose
services:
  mysql:
    image: mysql:9.7
    environment:
      MYSQL_ROOT_PASSWORD: example
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 5s
      timeout: 3s
      retries: 10

  mysqlsh:
    image: snickerjp/docker-mysql-shell:latest
    stdin_open: true
    tty: true
    command: ["--uri", "mysql://root:example@mysql:3306", "--sql"]
    depends_on:
      mysql:
        condition: service_healthy

⁠Command-Line Options

The ENTRYPOINT of this image is mysqlsh. Arguments passed to docker run are forwarded directly as mysqlsh options.

OptionDescription
--uri=<value>Connect using URI format (mysql://user:pass@host:port/schema)
--sqlStart in SQL mode
--jsStart in JavaScript mode
--pyStart in Python mode
-f, --file=<file>Execute a script file
-e, --execute=<cmd>Execute a command and exit
--json[=pretty]Output in JSON format
--quiet-start[={1|2}]Suppress startup information
--clusterEnsure connection to an InnoDB Cluster member
--API Command Line (e.g. -- util check-for-server-upgrade)

For all options, run docker run --rm snickerjp/docker-mysql-shell:latest --help.

⁠Environment Variables

This image does not define custom environment variables. The following are standard variables recognized by mysqlsh:

VariableDescriptionDefault
MYSQL_PWDMySQL password (deprecated, use --password)None
MYSQL_TCP_PORTDefault TCP port3306
MYSQL_HOSTDefault hostNone
MYSQL_UNIX_PORTUnix socket pathNone
⁠Examples
# Disable color output
docker run -it --rm -e MYSQLSH_TERM_COLOR_MODE=nocolor \
  snickerjp/docker-mysql-shell:latest --uri mysql://root@host:3306

# Mount config directory
docker run -it --rm \
  -v ./mysqlsh-config:/home/mysqlshelluser/.mysqlsh \
  snickerjp/docker-mysql-shell:latest

⁠Volumes

PathPurpose
/home/mysqlshelluser/.mysqlshMySQL Shell configuration and history
Any mount pointFor SQL scripts or SSL certificates

⁠Ports

This image does not EXPOSE any ports. MySQL Shell is a client tool and does not listen as a server.

⁠Building

cd docker
docker build -t snickerjp/docker-mysql-shell:9.7 .

⁠How It Works

⁠Automatic Version Updates

Every Friday, the check-new-release⁠ workflow runs and automatically creates a PR when a new MySQL Shell version is available.

⁠Docker Image Push

When a PR is merged, the docker-push⁠ workflow pushes the image to Docker Hub with multiple tags.

⁠Dockerfile

⁠Architecture

  • Base image: Debian 13 slim
  • Platform: linux/amd64
  • Non-root user: mysqlshelluser
  • ENTRYPOINT: mysqlsh
  • Default CMD: --version

Tag summary

Content type

Image

Digest

sha256:ea19a81ca…

Size

202.5 MB

Last updated

1 day ago

docker pull snickerjp/docker-mysql-shell