To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
BONUS Portainer
Cancel

Docker for efficient development

Lesson 3 - Available Databases on Docker Hub

In this tutorial, we’ll show you how easy it is to get MariaDB and Postgres up and running with Docker containers. Containers let you spin up databases quickly, isolate environments, and keep everything lightweight — perfect for development and production!


  1. Step 1: Understand the available database images
    • There are tons of Docker images available for popular databases like DB2, MySQL, MariaDB, Postgres, SQL Server (2017–2022), and various Oracle versions.
    • Today, we focus on MariaDB and Postgres to show you practical setups and cool Docker features.
  2. Step 2: Set up MariaDB with Docker Compose
    • Docker Compose file
    • Your compose file includes the container name, image (mariadb), and environment variables:
      • MYSQL_ROOT_PASSWORD set to root
      • MYSQL_DATABASE (database created at startup)
      • MYSQL_USER and MYSQL_PASSWORD for your user
    • Data storage
      • Instead of Docker volumes, MariaDB uses a local directory mapped to /config in the container with a data subfolder for database files.
    • Run the container
      • Open PowerShell and run:
      • (Without the -d flag to see live logs.)
    • Verify data folder
      • On your local machine, check the mapped folder — all your databases are stored here.
      • Tip: You can migrate existing MariaDB databases by copying files into this folder!
    • Stop the container
      • Press CTRL + C in the terminal to stop MariaDB.
  3. Step 3: Set up Postgres with Docker Compose
    • Docker Compose file includes:
      • The main postgres container with environment variables:
        POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD
      • A Docker volume mapped to /data/postgres for persistent storage
      • Port mapping for the default Postgres port (5432)
    • Multiple services in one file:
      • Postgres database container
      • PGAdmin: A web-based Postgres management UI
      • Automatic backup service that runs scheduled backups every minute, keeping backups daily, weekly, monthly, and up to six months
    • Run the containers
      • Open PowerShell and run:
    • Access PGAdmin
      • Open your browser at localhost:<PGAdmin_port>
      • Log in with the configured email and password from your compose file
    • Connect PGAdmin to Postgres
      • Click “Add New Server”
      • Use the container name as the hostname (Postgres runs on a private Docker network)
      • Enter your username and password (matching environment variables)
      • Save and connect!
    • Manage your database
      • From PGAdmin, you can see stats, create new databases, and explore your existing example database.
    • Backup folder
      • Check the local backups directory — your backups are compressed and organized by day, week, and month automatically, no downtime required.
  4. Step 4: Wrap-up and benefits
    • Containers let you host multiple isolated databases easily.
    • Smaller disk and memory footprint compared to VMs.
    • No need for Windows licenses for your dev environments.
    • Simple migration of existing data by copying files.
    • Automated backups keep your data safe without interrupting service.

That’s it! Containers make managing databases faster and smoother. Ready to get started? Watch our bonus lesson on Portainer to level up your Docker game even more.