Portainer Templates logo

Portainer Templates

MySQL MySQL

Container

Database

The most popular open-source database

Image details

Pulls: 178.9M
Architecture: amd64, arm64, arm64/v8
Image size: 156 MB
Latest: 8.0.32-1.2.11-server
User: mysql
Created: Mar 11, 2015
Updated: 3 years ago
Status: active

Source details

Stars: 12.4k
Forks: 4k
Language: C++
Updated: 5 days ago

Configuration

Type
Container
Platform
linux
Image
mysql/mysql-server:5.7
Ports
3306/tcp
Volumes
/var/lib/mysql
Env vars
MYSQL_ROOT_PASSWORD=''MYSQL_ROOT_HOST=%

Template by portainer

Standalone Install

Select an install method, to see config/commands for deploying MySQL

Installation method

Install on Portainer

Import all app templates into your Portainer instance, for easy 1-click deploys

  1. Ensure both Docker and Portainer are installed, and up-to-date
  2. Log into your Portainer web UI
  3. Under Settings → App Templates, paste the below URL
  4. Head to Home → App Templates, and the list of apps will show up
  5. Select MySQL, fill in any config options, and hit Deploy

Template Import URL

https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me demo

More install options in our documentation, or see mysql/mysql-server for app-specific guidance.

logo

What is MySQL?

MySQL is the world's most popular open source database. With its proven performance, reliability, and ease-of-use, MySQL has become the leading choice of database for web applications of all sorts, ranging from personal websites and small online shops all the way to large-scale, high profile web operations like Facebook, Twitter, and YouTube.
For more information and related downloads for MySQL Server and other MySQL products, please visit .

Supported Tags and Respective Dockerfile Links

Warning
The MySQL Docker images maintained by the MySQL team are built specifically for Linux platforms. Other platforms are not supported, and users using these MySQL Docker images on them are doing so at their own risk. See the discussion here for some known limitations for running these containers on non-Linux operating systems.

These are tags for some of the optimized MySQL Server Docker images, created and maintained by the MySQL team at Oracle (for a full list, see the Tags tab of this page).


Images are updated when new MySQL Server maintenance releases and development milestones are published. Please note that any non-GA releases are for preview purposes only and should not be used in production setups.
We also from time to time publish special MySQL Server images that contain experimental features.

Quick Reference


  • Where to file issues: Please submit a bug report at under the category “MySQL Package Repos and Docker Images”.

  • Maintained by: The MySQL team at Oracle


  • Supported Docker versions: The latest stable release is supported. Support for older versions (down to 1.0) is provided on a best-effort basis, but we strongly recommend using the most recent stable Docker version, which this documentation assumes.

How to Use the MySQL Images

Downloading a MySQL Server Docker Image

Downloading the server image in a separate step is not strictly necessary; however, performing this before you create your Docker container ensures your local image is up to date.
To download the MySQL Community Edition image, run this command:
shell> docker pull mysql/mysql-server:tag
  Refer to the list of supported tags above. If `:tag
` is omitted, the `latest` tag is used, and the image for the latest GA version of MySQL Server is downloaded.

Starting a MySQL Server Instance

Start a new Docker container for the MySQL Community Server with this command:
shell> docker run --name=mysql1 -d mysql/mysql-server:tag
  The --name option, for supplying a custom name for your server container (mysql1 in the example), is optional; if no container name is supplied, a random one is generated. If the Docker image of the specified name and tag has not been downloaded by an earlier docker pull or docker run command, the image is now downloaded. After download completes, initialization for the container begins, and the container appears in the list of running containers when you run the docker ps command; for example:
shell> docker ps
CONTAINER ID   IMAGE                COMMAND                  CREATED             STATUS                              PORTS                NAMES
a24888f0d6f4   mysql/mysql-server   "/entrypoint.sh my..."   14 seconds ago      Up 13 seconds (health: starting)    3306/tcp, 33060/tcp  mysql1
 
The container initialization might take some time. When the server is ready for use, the STATUS of the container in the output of the docker ps command changes from (health: starting) to (healthy).
The -d option used in the `docker
run` command above makes the container run in the background. Use this command to monitor the output from the container:

    shell> docker logs mysql1
  Once initialization is finished, the command's output is going to contain the random password generated for the root user; check the password with, for example, this command:
shell> docker logs mysql1 2>&1 | grep GENERATED
GENERATED ROOT PASSWORD: Axegh3kAJyDLaRuBemecis&EShOs
 

Connecting to MySQL Server from within the Container

Once the server is ready, you can run the mysql client within the MySQL Server container you just started and connect it to the MySQL Server. Use the docker exec -it command to start a mysql client inside the Docker container you have started, like this:
shell> docker exec -it mysql1 mysql -uroot -p
  When asked, enter the generated root password (see the instructions above on how to find it). Because the MYSQL_ONETIME_PASSWORD option is true by default, after you have connected a mysql client to the server, you must reset the server root password by issuing this statement:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
  Substitute password with the password of your choice. Once the password is reset, the server is ready for use.

Products Included in the Container

A number of MySQL products are included in the Docker container you created with the MySQL Server Docker image:

More Topics on Deploying MySQL Server with Docker

For more topics on deploying MySQL Server with Docker like starting and connecting to the server, server configuration, persisting data and configuration, server error log, server upgrades, and the Docker environment variables, see Deploying MySQL Server with Docker in the MySQL Server manual.

Serve MySQL on your own domain behind Caddy, Nginx or Traefik. Fill in your domain and copy the result. It's a starting point, some apps need their own base URL or extra headers set too.

Proxying mysql.example.com to http://mysql:3306

Add this to your Caddyfile

mysql.example.com {
	reverse_proxy http://mysql:3306
}

Check the logs first

Nine times out of ten the logs tell you exactly what went wrong.

  • In Portainer, go to Containers, click the container, then Logs. Or run docker logs <container>
  • Exit codes help too: 137 means killed, usually out of memory. 126 or 127 means the command inside the image is broken.

Published on a random port

This template exposes 3306/tcp without setting a host port, so Docker picks a random free one on every deploy.

  • Find it in the Ports column of Portainer's container list, or with docker port <container>

Image won't pull

Test the pull directly on the host: docker pull mysql/mysql-server:5.7

  • "manifest unknown" means the tag no longer exists.
  • "toomanyrequests" is the Docker Hub rate limit. Log in with docker login to raise it.
  • "no space left on device" means a full disk. Reclaim space with docker system prune

"exec format error"

This means the image was built for a different CPU architecture than your server.

  • This image supports: amd64, arm64, arm64/v8
  • Check yours with uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.

Required settings are blank

MYSQL_ROOT_PASSWORD has no default value, and the app may crash or misbehave if left empty.

  • Fill it in on the deploy screen before hitting deploy.

Raise an issue

Found something which isn't working as it should? Here's how to report it.

A single container

MySQL runs as one container, the simplest kind of app here. Just the one image to pull and nothing else wired up alongside it.

The app image

An image is the app packed up ready to go, everything MySQL needs bundled into one download. This template pulls mysql/mysql-server:5.7, which Docker fetches once (about 156 MB) and then starts your own copy from.

Where the image comes from

Docker pulls its images from registries, public libraries of ready-built apps. MySQL's comes from Docker Hub, published by mysql.

Version tags

The bit after the colon in the image name is the version tag. This one pins 5.7, so every redeploy gives you that exact build until you bump it yourself.

Which machines it runs on

Every image is built for particular CPU types. This one ships for amd64, arm64, arm64/v8, so it runs on both regular x86 servers and ARM boards like a Raspberry Pi.

Ports

A port is the door the app answers on. Here the app exposes a port but leaves the host side blank, so Docker picks a free one for you. It opens:

  • 3306, published on a random host port

Volumes

A volume is where MySQL keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:

  • /var/lib/mysql as a volume Docker manages for you

Environment variables

Environment variables are the settings you hand over when you deploy, things like a password or a timezone. MySQL takes 2 of them, and one needs a value before it'll start properly:

  • MYSQL_ROOT_PASSWORD, needs a value. Root password
  • MYSQL_ROOT_HOST, defaults to %

Networking

Nothing custom is set, so MySQL sits on Docker's default bridge network: its own private space that reaches the outside world only through the ports it publishes.

Platform

The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.

Portainer app templates

Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set MySQL up. Add the template list to Portainer once, then deploying MySQL is a click rather than a wall of config.