MySQL on Docker - How to Containerize Your Database

This whitepaper covers the basics you need to understand when considering to run a MySQL service on top of Docker container virtualization. And although Docker can help automate deployment of MySQL, the database still has to be managed and monitored. ClusterControl by Severalnines can provide a complete operational platform for production database workloads.

Table of contents

  • 1. Introduction
  • 2. Introduction to Docker
    • 2.1. Concept
    • 2.2. Components
    • 2.3. Benefits
    • 2.4. Installation
  • 3. MySQL Images
    • 3.1. Commit changes of a container
    • 3.2. Using Dockerfile
    • 3.3. Building the Image
    • 3.4. Sharing the Image
    • 3.5. Best Practice for MySQL
  • 4. Networking in Docker
    • 4.1. Host Network
    • 4.2. Bridge Network
      • 4.2.1. Default Bridge
      • 4.2.2. User-defined Bridge
    • 4.3. Multi-host Network
      • 4.3.1. Default Overlay
      • 4.3.2. User-defined Overlay
    • 4.4. Network Plugins
    • 4.5. Accessing the MySQL Containers
      • 4.5.1. Container’s exposed port
      • 4.5.2. Container’s published port
      • 4.5.3. Attaching to the active container
  • 5. MySQL Container and Volume
    • 5.1. Running a Single MySQL Container
    • 5.2. Running Multiple MySQL Containers
    • 5.3. Container Layer Changes
    • 5.4. MySQL Persistency
    • 5.5. Docker Volume
      • 5.5.1. Persistent Volume
      • 5.5.2. Non-Persistent Volume
      • 5.5.3. Remote Volume
    • 5.6. Volume Drivers
    • 5.7. Performance Tradeoff
  • 6. Monitoring and Management
    • 6.1. Service Control
    • 6.2. Resource Control
    • 6.3. Resource Monitoring
    • 6.4. Configuration Management
    • 6.5. Security
      • 6.5.1. Unprivileged Container
      • 6.5.2. Privileged Container
    • 6.6. Backup and Restore
    • 6.6.1. Backup
    • 6.6.2. Restore
    • 6.7. Upgrades
      • 6.7.1. Logical Upgrade
      • 6.7.2. In-Place Upgrade
    • 6.8. Housekeeping
  • 7. ClusterControl on Docker
    • 7.1. Running ClusterControl as Docker Container
    • 7.2. Automatic Database Deployment
    • 7.3. Manual Database Deployment
    • 7.4. Add Existing Database Containers
  • 8. Summary

Introduction

Docker is quickly becoming mainstream, as a method to package and deploy self-sufficient applications in primarily stateless Linux containers. Yet, for a stateful service like a database, this might be bit of a headache. How do we best configure MySQL in a container environment? What can go wrong? Should we even run our databases in a container environment? How does performance compare with e.g. running on virtual machines or bare-metal servers? How do we manage replicated or clustered setups, where multiple containers need to be created, upgraded and made highly available?

This whitepaper covers the basics you need to understand considering to run a MySQL service on top of Docker container virtualization. Take note that this whitepaper does not cover MySQL container orchestration on multiple hosts.

Want to read the rest?

Download the full whitepaper for free