What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Run MariaDB as a container using the official MariaDB Docker image, pin an explicit image tag, load credentials through Docker secrets, mount a named volume at /var/lib/mysql, and keep port 3306 off the public internet. The procedure below creates a database and application user, verifies readiness, explains first-start behavior, and provides backup, restore, upgrade, and recovery steps for a Linux VPS.

What you are building

A VPS deployment normally has three layers:

  • The Linux host runs Docker Engine and the Docker Compose plugin.
  • A MariaDB container runs the database server.
  • Your application connects to MariaDB over a private Docker network, using the Compose service name as its hostname.

Docker isolates the process and makes the image version reproducible, but it does not make database administration optional. You still need durable storage, controlled credentials, backups, updates, and host firewall rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the maintained official image from Docker Hub. Its packaging is maintained in the MariaDB Corporation Docker repository. Docker Hub provides moving latest and lts tags, but tags can change over time, so production deployments should resolve an explicit version tag and keep that choice under change control.

Prerequisites on the VPS

Host and access

  • A Linux VPS with enough disk space for the database, transaction logs, backups, and future growth.
  • Administrative SSH access and a host firewall.
  • Docker Engine with Docker Compose support installed and working for your deployment user.
  • A plan for storing backups outside the container’s writable layer and, preferably, outside the VPS.

Do not treat a container’s writable layer as database storage. Containers can be recreated; the named volume described below must outlive the container.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

Network plan

Decide whether an application will run on the same Docker host. If it will, place both services on a shared private network and publish no MariaDB port. If you need administration from the VPS itself, use a loopback-only binding such as 127.0.0.1:3306:3306; that exposes the port to processes on the host but not to the public network. Do not bind MariaDB to 0.0.0.0 on an Internet-facing VPS.

Choose and pin the MariaDB image

Open the official image page and select a version line that is currently supported for your application. Avoid using latest in production: it can move to a different major release when you redeploy. The lts tag identifies the last long-term-support release according to Docker Hub, but it also moves when a newer LTS becomes current. An explicit version tag gives you a stable starting point for testing and upgrades.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Compose example uses an environment variable for the tag so the selected version is visible and reviewable:

MARIADB_IMAGE_TAG=10.11

The value above is only an example of an explicit tag format. Check the current tags and support status on Docker Hub before choosing a value, then test that exact value in a staging environment.

Create a project and secret files

Create a directory with separate locations for the Compose file and credentials. Restrict the directory and secret files so ordinary users cannot read database passwords.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
mkdir -p ~/mariadb-docker/secrets
cd ~/mariadb-docker
umask 077
openssl rand -hex 32 > secrets/mariadb_root_password
openssl rand -hex 32 > secrets/mariadb_app_password
printf 'MARIADB_IMAGE_TAG=10.11n' > .env
chmod 600 .env secrets/mariadb_root_password secrets/mariadb_app_password

Generate different random values for the root and application accounts. Never copy a password from a tutorial into a public server, commit the files to source control, or paste credentials into a command line where they will remain in shell history.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Docker’s official image accepts a required root credential through one of MARIADB_ROOT_PASSWORD_HASH, MARIADB_ROOT_PASSWORD, MARIADB_ALLOW_EMPTY_ROOT_PASSWORD, or MARIADB_RANDOM_ROOT_PASSWORD, with a corresponding _FILE form for each variable. An empty root password is unsuitable for a VPS. The Compose file below uses MARIADB_ROOT_PASSWORD_FILE so the secret value is read from a mounted file rather than written into YAML.

Write a secure Compose file

Create compose.yml with this service definition:

services:
  mariadb:
    image: mariadb:${MARIADB_IMAGE_TAG}
    restart: unless-stopped
    environment:
      MARIADB_ROOT_PASSWORD_FILE: /run/secrets/mariadb_root_password
      MARIADB_DATABASE: appdb
      MARIADB_USER: appuser
      MARIADB_PASSWORD_FILE: /run/secrets/mariadb_app_password
    secrets:
      - mariadb_root_password
      - mariadb_app_password
    volumes:
      - mariadb_data:/var/lib/mysql
    networks:
      - backend
    healthcheck:
      test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
      interval: 10s
      timeout: 5s
      retries: 10

secrets:
  mariadb_root_password:
    file: ./secrets/mariadb_root_password
  mariadb_app_password:
    file: ./secrets/mariadb_app_password

volumes:
  mariadb_data:

networks:
  backend:

This is a community-style Compose pattern, not an official Compose template. The health check uses the image’s healthcheck.sh with --connect and --innodb_initialized; it indicates that the server can accept a connection and InnoDB has initialized, which is more useful to dependent services than merely checking whether a process exists.

What each setting does

Setting Purpose Important qualification
image Selects the official MariaDB image and the tag you chose. Keep the tag explicit; moving tags can change between deployments.
restart: unless-stopped Restarts the service after a crash or host reboot unless you deliberately stopped it. This does not replace monitoring or backups.
MARIADB_ROOT_PASSWORD_FILE Supplies the administrative credential from a Docker secret file. The file is consumed during initialization; changing it later does not alter an existing account.
MARIADB_DATABASE Requests creation of appdb on first initialization. It is not a migration mechanism for an already populated data directory.
MARIADB_USER and MARIADB_PASSWORD_FILE Create an application account and grant it privileges on the requested database. The image creates the account only when both a user and a password are supplied.
mariadb_data:/var/lib/mysql Stores MariaDB’s data directory in a named Docker volume. The volume must be retained when the container is recreated.
No ports entry Keeps TCP 3306 off the VPS’s public interfaces. Services on the backend network reach the database at hostname mariadb.

From image tags 10.2.38, 10.3.29, 10.4.19, 10.5.10 and all 10.6 and newer tags, MARIADB_* variables take precedence over the older MYSQL_* names. Use the MariaDB-prefixed names in new deployments; treat older examples using MYSQL_* as legacy configuration.

Validate and start the container

  1. Check interpolation and syntax. From the project directory, run docker compose config. Confirm that the rendered service uses the intended image tag, secret file paths, volume, and network. Do not paste the rendered output into a public issue if it contains sensitive values.
  2. Pull the selected image. Run docker compose pull mariadb. Review the tag before proceeding; this is the point to stop if the tag is not the version you approved.
  3. Start in detached mode. Run docker compose up -d mariadb.
  4. Watch startup. Run docker compose logs -f mariadb in a separate session. The first startup initializes the data directory and may take longer than later starts.
  5. Check service state. Run docker compose ps. Wait for the health status to become healthy before configuring an application that depends on the database.

The official image also documents a minimal first-run command, docker run --detach --name some-mariadb --env MARIADB_ROOT_PASSWORD=my-secret-pw mariadb:latest. That command is a test example only: it uses a moving tag, puts a password in the command line, has no persistent volume, and publishes no deliberate production policy. Do not copy it unchanged to a public VPS.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Connect an application over the private network

An application container attached to backend should use:

  • Host: mariadb, the Compose service name.
  • Port: 3306, the container’s internal MariaDB port.
  • Database: appdb.
  • User: appuser.
  • Password: the value stored in secrets/mariadb_app_password, injected into the application by its own secret mechanism.

Do not configure the application to use localhost for the database unless both processes are in the same container. Inside an application container, localhost refers to that application container itself, not the MariaDB service.

If the application runs directly on the VPS rather than in Docker, add a loopback-only port mapping to the MariaDB service:

    ports:
      - '127.0.0.1:3306:3306'

Then the host-based application can use 127.0.0.1:3306. This mapping is different from a public binding; still verify the VPS firewall and cloud security-group rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand first initialization and persistence

The environment variables that create accounts, set passwords, and create a database are initialization inputs. On startup, the image leaves an existing data directory untouched. Therefore, changing MARIADB_DATABASE, MARIADB_USER, or a password variable after the volume has been initialized does not retroactively change the database.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Safe lifecycle commands

  • docker compose stop stops the service without removing its container or volume.
  • docker compose start starts an existing stopped service.
  • docker compose down removes the Compose containers and network but leaves the named volume by default.
  • docker compose up -d recreates the service while reusing the named volume.

Never use docker compose down -v casually. The -v option removes named volumes, including mariadb_data, and destroys the database stored there unless you have an independent backup and intentionally want to erase the volume.

Changing a password after deployment

To rotate a credential, first create the new secret file with restrictive permissions, then connect as an administrator and run an explicit SQL account change for the actual account and host entry. Verify the account’s host with SELECT User, Host FROM mysql.user;; do not assume that an account’s host pattern is identical in every deployment. Update the application only after the SQL change succeeds, and remove the old secret from systems that no longer need it. Editing the Compose environment variable alone cannot change an account in an existing data directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Back up MariaDB correctly

Do not back up a live database by copying the raw contents of /var/lib/mysql from the Docker volume. Use a logical dump with mysqldump or a physical backup tool such as mariabackup, then copy the resulting backup to storage independent of the VPS.

Logical dump with a password prompt

mkdir -p ~/mariadb-backups
chmod 700 ~/mariadb-backups
docker compose exec -T mariadb mysqldump -u root -p --all-databases --single-transaction --routines --events > ~/mariadb-backups/mariadb-$(date +%F).sql

The -p option prompts for the root password instead of placing it in the command. --single-transaction is appropriate for transactional InnoDB tables because it avoids a long table lock for the dump; confirm your workload and table engines before relying on that behavior for non-InnoDB data.

Restore a dump

For a restore, stop applications that write to the database, use a clean target or a deliberate restoration plan, and run:

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
docker compose exec -T mariadb mariadb -u root -p < ~/mariadb-backups/mariadb-2026-10-14.sql

Replace the filename with the backup you have verified. A restore overwrites or recreates objects represented in the dump; take a current backup before attempting it on a live database.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test the backup

A backup is useful only if it can be read. Periodically restore a copy into an isolated MariaDB container or staging VPS, verify that the expected databases and tables exist, and exercise an application read. Keep the test separate from production so a restore cannot damage the live volume.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep port 3306 and the VPS locked down

Docker network exposure

Do not add a public 3306:3306 mapping merely because a database client cannot connect. First determine whether the client should run inside the Docker network. If host-level administration is necessary, bind only to 127.0.0.1 and use an SSH tunnel or another controlled access path rather than opening the database to the Internet.

Host firewall

At the VPS firewall and any cloud security group, allow only the SSH port and the web ports your service actually needs. Keep MariaDB absent from the allowed public ingress list. A Docker port publication can bypass assumptions about a host firewall, so inspect the effective published ports with docker compose ps and your firewall tooling.

Credentials and files

  • Use unique, randomly generated root and application passwords.
  • Keep .env and the secret directory readable only by the deployment account.
  • Prefer the _FILE variables for every supported secret rather than committing plaintext values to Compose.
  • Do not reuse a root password as the application password.
  • Grant the application account only the database access it needs; use the root account for administration, not routine application queries.

Database operations

For production workloads, enable slow-query logging and size the InnoDB buffer pool based on the VPS memory budget and workload. These are host and MariaDB tuning tasks rather than Docker settings; change them deliberately and monitor disk, memory, CPU, and query latency after each change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Upgrades without losing the data volume

  1. Read the release notes for the target MariaDB version and confirm that your application and connectors support it.
  2. Run and verify a logical dump or a mariabackup backup before changing the image tag.
  3. Record the current tag and the output of docker compose ps so you can identify the previous image during rollback planning.
  4. Change MARIADB_IMAGE_TAG to the approved explicit tag.
  5. Pull and recreate the service with docker compose pull mariadb followed by docker compose up -d mariadb. Do not add -v.
  6. Follow startup logs, wait for the health check, and connect with the application account.
  7. Run application smoke tests and inspect error logs before declaring the upgrade complete.

Keep the named volume and the backup until the new version has passed validation. If the new image cannot start, stop the service, preserve the failed volume for investigation, and use your tested backup or documented rollback procedure rather than deleting data in an attempt to make the container start.

Troubleshooting common failures

Symptom Likely cause Action
The container exits immediately and logs mention a missing root credential. No accepted root-password variable or file was supplied. Check that MARIADB_ROOT_PASSWORD_FILE points to a mounted secret and that the file exists and is readable by the container.
Password or database changes in Compose have no effect. The named volume already contains an initialized data directory. Change the account or schema with SQL, or intentionally reinitialize only after a verified backup and an explicit data-destruction decision.
The application reports “connection refused” using localhost. The application is in a different container, so its localhost is not the MariaDB service. Attach both services to the same network and use hostname mariadb, or use a loopback mapping only for an application running on the VPS host.
The application cannot resolve mariadb. The application and database are not attached to the same Docker network, or the service name differs. Inspect the rendered Compose configuration and both services’ network declarations.
A deployment unexpectedly uses a different MariaDB major version. The image used latest, lts, or another moving tag. Pin an explicit tag, record it in version control, and upgrade it as a deliberate change.
Data disappears after cleanup. docker compose down -v removed the named volume. Restore from a dump or physical backup; for future cleanup, omit -v unless volume deletion is intentional.
A password appears in shell history or a process listing. The secret was passed directly in a command or plaintext environment. Rotate the credential, use a secret file and an interactive prompt, and remove exposed command history where appropriate.
The service is running but dependent services start too soon. Container running state was mistaken for database readiness. Use the health check and configure dependent services to wait for a healthy MariaDB service.

Operational checklist

  • Official mariadb image selected from Docker Hub.
  • Explicit image tag reviewed and recorded; no production reliance on latest.
  • MARIADB_* variables used instead of legacy MYSQL_* names.
  • Root and application credentials generated uniquely and loaded through _FILE secrets.
  • Named volume mounted at /var/lib/mysql.
  • No public 3306 publication; application traffic stays on a private Docker network.
  • Health check enabled and startup logs reviewed.
  • Logical or physical backups created with a tested restore procedure.
  • Firewall allows only required SSH and web traffic.
  • Password rotation and image upgrades are performed as explicit SQL and deployment changes, not by editing variables alone.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.