Percona Server
Stack
Percona Server for MySQL - a free, fully MySQL-compatible drop-in with extra instrumentation (detailed INFORMATION_SCHEMA and PERFORMANCE_SCHEMA tables), improved diagnostics, and performance enhancements.
Image details
Configuration
TypeComposelinuxpercona/percona-server:8.03306:3306/var/lib/mysql : perconadataMYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}MYSQL_DATABASE=${MYSQL_DATABASE:-app}MYSQL_USER=${MYSQL_USER:-app}MYSQL_PASSWORD=${MYSQL_PASSWORD}unless-stoppedTemplate by deployable-sh·Source
Report issueStandalone Install
Select an install method, to see config/commands for deploying Percona Server
Install on Portainer
Import all app templates into your Portainer instance, for easy 1-click deploys
- Ensure both Docker and Portainer are installed, and up-to-date
- Log into your Portainer web UI
- Under Settings → App Templates, paste the below URL
- Head to Home → App Templates, and the list of apps will show up
- Select Percona Server, fill in any config options, and hit Deploy
Template Import URL
https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me
Original stackfile
The compose file this template deploys, straight from its repo:
name: percona-server
services:
percona:
image: percona/percona-server:8.0
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE:-app}
MYSQL_USER: ${MYSQL_USER:-app}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "3306:3306"
volumes:
- perconadata:/var/lib/mysql
volumes:
perconadata:
Or deploy it directly from the source:
git clone https://github.com/deployable-sh/stacks
cd stacks
docker compose -f percona-server/compose.yaml up -dMore install options in our documentation, or see percona/percona-server for app-specific guidance.

What is Percona Server?
Percona Server is an enhanced drop-in replacement for MySQL. With Percona Server, your queries will run faster and more consistently. You will consolidate servers on powerful hardware and will delay sharding, or avoid it entirely.For more information and related downloads for Percona Server and other Percona products, please visit http://www.percona.com.
Percona Server Docker Images
These are the only official Percona Server Docker images, created and maintained by the Percona team. The image has the Percona Fractal Tree based storage engineTokuDB enabled. The available versions are:Percona Server 8.0.15-6.1 (tag: 8.0)Images are updated when new releases are published.How to Use the Images
Start a Percona Server Instance
Start a Percona Server container as follows:docker run --name container-name -e MYSQL_ROOT_PASSWORD=secret -d percona/percona-server:tagWhere container-name is the name you want to assign to your container, secret is the password to be set for the root user and tag is the tag specifying the version you want. See the list above for relevant tags, or look at the full list of tags.Connect to Percona Server from an Application in Another Docker Container
This image exposes the standard MySQL port (3306), so container linking makes the instance available to other containers. Start other containers like this in order to link it to the Percona Server container:docker run --name app-container-name --link container-name -d app-that-uses-mysqlConnect to Percona Server from the MySQL Command Line Client
The following command starts another container instance and runs themysql command line client against your original container, allowing you to execute SQL statements against your database:docker run -it --link container-name --rm percona/percona-server:tag mysql -h container-name -P 3306 -uroot -psecret'where container-name is the name of your database container.Environment Variables
When you start a Percona Server container, you can adjust the configuration of the instance by passing one or more environment variables on thedocker run command line. Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.Most of the variables listed below are optional, but one of the variables
MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD, MYSQL_RANDOM_ROOT_PASSWORD must be given.MYSQL_ROOT_PASSWORD
This variable specifies a password that will be set for the root superuser account. In the above example, it was set to secret. NOTE: Setting the MySQL root user password on the command line is insecure.MYSQL_ROOT_PASSWORD_FILE
This variable specifies a file that will be read for the root user account. This can be a mounted file when you run your container. This can also be used in the scope of the Docker Secrets (Swarm mode) functionality.MYSQL_RANDOM_ROOT_PASSWORD
When this variable is set to yes, a random password for the server's root user will be generated. The password will be printed to stdout in the container, and it can be obtained by using the command docker logs container-name.MYSQL_ONETIME_PASSWORD
This variable is optional. When set to yes, the root user's password will be set as expired, and must be changed before we can login normally. This is only supported by version 5.6 or newer.MYSQL_DATABASE
This variable is optional. It allows you to specify the name of a database to be created on image startup. If a user/password was supplied (see below) then that user will be granted superuser access (corresponding to GRANT ALL) to this database.MYSQL_USER, MYSQL_PASSWORD
These variables are optional, used in conjunction to create a new user and set that user's password. This user will be granted superuser permissions (see above) for the database specified by the MYSQL_DATABASE variable. Both variables are required for a user to be created.Do note that there is no need to use this mechanism to create the
root superuser, that user gets created by default with the password set by either of the mechanisms (given or generated) discussed above.MYSQL_ALLOW_EMPTY_PASSWORD
Set to yes to allow the container to be started with a blank password for the root user. NOTE: Setting this variable to yes is not recommended unless you really know what you are doing, since this will leave your instance completely unprotected, allowing anyone to gain complete superuser access.INIT_TOKUDB
Set to 1 to allow the container to be started with enabled TOKUDB engine.INIT_ROCKSDB
Set to 1 to allow the container to be started with enabled ROCKSDB engine.MYSQL_INIT_ONLY
Set to 1 will skip starting the mysqld process and will run only the initialization part if MySQL was not initialized before.Notes, Tips, Gotchas
Secure Container Startup
In many use cases, employing theMYSQL_ROOT_PASSWORD variable to specify the MySQL root user password on initial container startup is insecure. Instead, to keep your setup as secure as possible, we strongly recommend using the MYSQL_RANDOM_ROOT_PASSWORD option. To further secure your instance, we also recommend using the MYSQL_ONETIME_PASSWORD variable if you use version 5.6 or higher.Where to Store Data
There are many two ways to store data used by applications that run in Docker containers. We maintain our usual stance and encourage users to investigate the options and use the method that best suits their use case. Here are some of the options available:- Let Docker manage the storage of your database data by writing the database files to disk on the host system using its own internal volume management. The current solutions, devicemapper, aufs and overlayfs have negative performance records.
- Create a data directory on the host system (outside the container on high performance storage) and mount this to a directory visible from inside the container. This places the database files in a known location on the host system, and makes it easy for tools and applications on the host system to access the files. The user needs to make sure that the directory exists, and that permissions and other security mechanisms on the host system are set up correctly.
The Docker documentation is a good starting point for understanding the different storage options and variations, and there are multiple blog and forum postings that discuss and give advice in this area. We will simply show the basic procedure here for the latter option above:
- Create a data directory on a suitable volume on your host system, e.g.
/local/datadir. - Start your container like this:
docker run --name container-name -v /local/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=secret -d percona/percona-server:tagThe
-v /local/datadir:/var/lib/mysql part of the command mounts the /local/datadir directory from the underlying host system as /var/lib/mysql inside the container, where MySQL by default will write its data files.Note that users on systems with SELinux enabled may experience problems with this. The current workaround is to assign the relevant SELinux policy type to the new data directory so that the container will be allowed to access it:
chcon -Rt svirt_sandbox_file_t /local/datadirExisting Data
If you start your MySQL container instance with a data directory that already contains a data (specifically, amysql subdirectory where all our system tables live), the $MYSQL_ROOT_PASSWORD variable should be omitted from the docker run command.Port forwarding
Docker allows mapping of ports on the container to ports on the host system by using the -p option. If you start the container as follows, you can connect to the database by connecting your client to a port on the host machine. This can greatly simplfy consolidating many instances to a single host. In this example port 6603, the we use the address of the Docker host to connect to the TCP port the Docker deamon is forwarding from:docker run --name container-name `-p 6603:3306` -d percona/percona-server
mysql -h docker_host_ip -P 6603Passing options to the server
You can pass arbitrary command line options to the MySQL server by appending them to therun command:docker run --name my-container-name -d percona/percona-server --option1=value --option2=valueIn this case, the values of option1 and option2 will be passed directly to the server when it is started. The following command will for instance start your container with UTF-8 as the default setting for character set and collation for all databases in MySQL:docker run --name container-name -d percona/percona-server --character-set-server=utf8 --collation-server=utf8_general_ciUsing a Custom Percona Server Config File
The Percona Server startup configuration in these Docker images is specified in the file/etc/my.cnf. If you want to customize this configuration for your own purposes, you can create your alternative configuration file in a directory on the host machine and then mount this file in the appropriate location inside the Percona Server container, effectively replacing the standard configuration file.If you want to base your changes on the standard configuration file, start your Percona Server container in the standard way described above, then do:
docker exec -it my-container-name cat /etc/my.cnf > /my/custom/config-file... where /my/custom/config-file is the path and name of the new configuration file. Then start a new Percona Server container like this:docker run --name my-new-container-name -v /my/custom/config-file:/etc/my.cnf -e MYSQL_ROOT_PASSWORD=my-secret-pw -d percona/percona-server:tagThis will start a new Percona Server container my-new-container-name where the Percona Server instance uses the startup options specified in /my/custom/config-file.Supported Docker Versions
These images are officially supported by the MySQL team on Docker version 1.9. Support for older versions (down to 1.0) is provided on a best-effort basis, but we strongly recommend running on the most recent version, since that is assumed for parts of the documentation above.User Feedback
We welcome your feedback!Serve Percona Server 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 percona-server.example.com to http://percona:3306
Add this to your Caddyfile
percona-server.example.com {
reverse_proxy http://percona: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:
137means killed, usually out of memory.126or127means the command inside the image is broken.
Port already in use
If deployment fails with "Bind for 0.0.0.0:3306 failed: port is already allocated", something else on your server is using that port.
- Find what's using it:
sudo ss -tlnp | grep :3306 - Stop the other service, or pick a different host port. In
3306:3306only the left number is yours to change, the right one belongs to the app.
Running but the page won't load
The container is up but nothing appears in your browser.
- Use your server's real IP:
http://your-server-ip:3306. The 0.0.0.0 link Portainer shows isn't a real address. - Give it a minute after first deploy, percona can take a while to initialise.
- Make sure your firewall allows the port, e.g.
sudo ufw allow 3306
Image won't pull
Test the pull directly on the host: docker pull percona/percona-server:8.0
- "manifest unknown" means the tag no longer exists.
- "toomanyrequests" is the Docker Hub rate limit. Log in with
docker loginto 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 - Check yours with
uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.
Container keeps restarting
The unless-stopped restart policy relaunches the app after every crash, so the real error can scroll past.
- Check the logs right after a restart, the last few lines before it died are the useful ones.
- Get the exit code with
docker inspect <container> --format '{{.State.ExitCode}}' - Still stuck? Redeploy once with the restart policy set to
noso the failure stays visible.
Stack won't deploy
Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.
- YAML only accepts spaces for indentation, a single tab breaks the whole file.
Raise an issue
Found something which isn't working as it should? Here's how to report it.
- Bug within the app: Open an issue on percona/percona-server
- Template not working: Open an issue on deployable-sh/stacks
- This website not working: Open an issue on lissy93/portainer-templates
A Compose stack
Percona Server is a Compose stack, a set of containers defined in one file and brought up together by Portainer, then started and stopped as a single app.
The app image
An image is the app packed up ready to go, everything Percona Server needs bundled into one download. This template pulls percona/percona-server:8.0, which Docker fetches once (about 437 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. Percona Server's comes from Docker Hub, published by percona.
Version tags
The bit after the colon in the image name is the version tag. This one pins 8.0, 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, 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. A mapping like 3306:3306 means it's reachable on port 3306 of your server, where the left number is yours to change and the right one belongs to the app. It opens:
3306:3306
Volumes
A volume is where Percona Server 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/mysqlkept in theperconadatavolume Docker manages
Environment variables
Environment variables are the settings you hand over when you deploy, things like a password or a timezone. Percona Server takes 4 of them, all with defaults you can leave alone or tweak:
MYSQL_ROOT_PASSWORD, pulled from your own environment. Root password (required).MYSQL_DATABASE, defaults toapp. Application database + user created on first boot.MYSQL_USER, defaults toappMYSQL_PASSWORD, pulled from your own environment
Restart policy
The restart policy here is unless-stopped, so Docker restarts Percona Server after a crash or reboot, but leaves it off when you stop it on purpose. You can change this on the deploy screen. The choices are no (never restart), on-failure (only after a crash), unless-stopped (restart unless you stop it), and always (bring it back no matter what).
Networking
Nothing custom is set, so Percona Server sits on Docker's default bridge network: its own private space that reaches the outside world only through the ports it publishes.
Container name
Once it's deployed, Portainer names the container percona. That's what you'll spot in the containers list and use in commands like docker logs percona.
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 Percona Server up. Add the template list to Portainer once, then deploying Percona Server is a click rather than a wall of config.