Running MySQL in Docker on Apple Silicon (M1): Troubleshooting "no matching manifest" Error
Reasons for the Error:
- Missing M1-Compatible Image: The MySQL image you're trying to use might not have a variant built for ARM architecture. Many software vendors haven't yet provided official ARM builds of their images.
- Incorrect Image Specification: If you're manually specifying the image tag, you might be using one that doesn't include an M1 variant.
Solutions:
-
Find an M1-Compatible MySQL Image:
-
Use a Multi-Arch Image (if available):
-
Build Your Own Image (advanced):
Additional Tips:
- Specify Platform in
docker run
: If you know the image has an M1 variant (e.g.,mysql:8.0.30-arm64
), you can explicitly specify the platform flag in thedocker run
command:docker run --platform linux/arm64 mysql:8.0.30-arm64
- Check Docker Version: Ensure you're using a Docker version that supports Apple Silicon. You can check your version with
docker version
.
Assuming you find an M1-compatible MySQL image on Docker Hub (e.g., mysql:8.0.30-arm64
), you can simply use it in your docker run
command:
docker run mysql:8.0.30-arm64
If the official MySQL image is multi-arch, Docker will automatically choose the M1 variant. No code changes are necessary in this case.
Specifying Platform in docker run (for Multi-Arch Images):
Even for multi-arch images, you can explicitly specify the platform flag for clarity:
docker run --platform linux/arm64 mysql:latest # Assuming 'latest' is multi-arch
Building Your Own Dockerfile (advanced):
Here's a basic example Dockerfile for building an M1-compatible MySQL image (replace placeholders with actual commands for installing MySQL on ARM):
FROM arm64/debian:buster AS builder
# Install build dependencies for MySQL (replace with actual commands)
RUN apt-get update && apt-get install -y build-essential ...
# Download and build MySQL from source (replace with actual commands)
WORKDIR /src
RUN curl -L https://dev.mysql.com/get/mysql-community-release_8.0.30-1debian11.tar.gz | tar -xzf -
RUN ./scripts/configure --prefix=/usr/local/mysql && make && make install
# Create the final image
FROM mysql:8.0 # Use a minimal MySQL image as base
# Copy configuration files and data volumes (optional)
COPY my.cnf /etc/mysql/my.cnf
COPY data.sql /var/lib/mysql/
# Expose the MySQL port
EXPOSE 3306
# Set the command to run MySQL
CMD ["mysqld"]
- MariaDB is a popular open-source fork of MySQL known for its compatibility with various architectures.
- This approach might require some adjustments to your application code or configuration if it specifically relies on MySQL features.
Use Docker in Rosetta Translation Mode (Transitional):
Important Note: This method is for transitional purposes only and might not be ideal for long-term use due to performance overhead.
- Apple's Rosetta technology can translate Intel-based (x86_64) applications to run on ARM processors.
- Enable Docker Desktop's Rosetta translation mode in its preferences.
- You can then try pulling the standard
mysql:latest
image, which is typically built for x86_64 architecture. - Be aware that this approach might have performance implications and potentially encounter compatibility issues with some software.
Consider Alternative Database Solutions (if applicable):
- If your project doesn't require the full functionality of MySQL or MariaDB, explore alternative database solutions that have native ARM support.
Remember:
- The best solution depends on your specific needs and project requirements.
- If you anticipate long-term use on Apple Silicon, using M1-compatible images or building your own Dockerfile for ARM architecture is the most future-proof approach.
- Keep an eye on official Docker images for MySQL, as support for ARM might become more prevalent in future releases.
mysql docker apple-silicon