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 one MySQL 8.4 container on a private Docker network, persist /var/lib/mysql on a named volume, and give every application its own database credentials. Do not publish port 3306 unless a host or external client genuinely needs database access. Deliver passwords through Docker Compose secrets and the MySQL image’s _FILE variables rather than committing them to docker-compose.yml.

This design lets several containers share one database server without sharing application credentials. It also keeps the data directory independent of the MySQL container, so replacing the container does not remove the database files. The examples below use Docker Compose and the official mysql:8.4 image; adapt the application-side password handling to your framework.

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

What the secure layout looks like

Each application connects to MySQL over a user-defined private network. Inside that network, Docker’s DNS resolves the Compose service name db to the MySQL container. Applications therefore use db as the hostname and 3306 as the port. No host port mapping is needed for container-to-container traffic.

  • One MySQL service: reduces the number of database servers you patch, monitor and back up.
  • One named volume: stores MySQL files outside the container’s writable layer.
  • One private network: limits database reachability to attached services.
  • One database and user per app: prevents one application from using another application’s credentials or schema.
  • Compose secrets: mount password files only into services that need them.

Docker describes same-network service-name discovery as the normal way for Compose services to communicate. MySQL’s Docker guidance likewise uses a Docker network so a client container can reach the server 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.

Before you deploy

Install a current Docker Engine or Docker Desktop release that includes the Compose v2 command, then create a project directory. The host must have enough disk space for the databases, backups and MySQL’s temporary files. Decide where durable backups will live before putting production data into the stack.

Create a private secrets directory and ensure it is excluded from version control:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mkdir -p mysql-stack/secrets
cd mysql-stack
touch secrets/db_root_password.txt secrets/app1_password.txt secrets/app2_password.txt
printf 'replace-with-a-long-random-root-passwordn' > secrets/db_root_password.txt
printf 'replace-with-a-long-random-app1-passwordn' > secrets/app1_password.txt
printf 'replace-with-a-long-random-app2-passwordn' > secrets/app2_password.txt
chmod 600 secrets/*.txt
printf 'secrets/n' >> .gitignore

Generate real random values with your organization’s approved password generator. The strings above are placeholders inside a command example, not credentials to use in production.

Compose file for a shared MySQL server

Save this as compose.yaml:

services:
  db:
    image: mysql:8.4
    restart: unless-stopped
    volumes:
      - mysql_data:/var/lib/mysql
    secrets:
      - db_root_password
      - app1_password
      - app2_password
    environment:
      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
      MYSQL_DATABASE: app1
      MYSQL_USER: app1
      MYSQL_PASSWORD_FILE: /run/secrets/app1_password
    networks:
      - backend
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h localhost -uroot -p"$$(cat /run/secrets/db_root_password)" --silent"]
      interval: 10s
      timeout: 5s
      retries: 12
      start_period: 30s

  app1:
    image: your-app1-image
    environment:
      DB_HOST: db
      DB_PORT: 3306
      DB_NAME: app1
      DB_USER: app1
      DB_PASSWORD_FILE: /run/secrets/app1_password
    secrets:
      - app1_password
    networks:
      - backend

  app2:
    image: your-app2-image
    environment:
      DB_HOST: db
      DB_PORT: 3306
      DB_NAME: app2
      DB_USER: app2
      DB_PASSWORD_FILE: /run/secrets/app2_password
    secrets:
      - app2_password
    networks:
      - backend

volumes:
  mysql_data:

networks:
  backend:
    internal: true

secrets:
  db_root_password:
    file: ./secrets/db_root_password.txt
  app1_password:
    file: ./secrets/app1_password.txt
  app2_password:
    file: ./secrets/app2_password.txt

The application image must actually support DB_PASSWORD_FILE. Many frameworks expect a password value rather than a filename; in that case, configure the application’s entrypoint or secret integration to read /run/secrets/app1_password or /run/secrets/app2_password and pass the contents to the database driver without logging them.

The internal: true network prevents ordinary external connectivity to that network. If an application needs outbound internet access, attach it to a second, deliberately configured network while keeping the database only on backend.

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

How the credentials and privilege boundaries work

Root is for administration only

MYSQL_ROOT_PASSWORD_FILE supplies the initial root password from a mounted secret file. Do not put that account in an application connection string. Root can create or drop databases, alter users and change server configuration, so a compromised application using root can compromise every database on the server.

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

App1 is created by the image

On the first initialization of an empty data directory, MYSQL_DATABASE: app1, MYSQL_USER: app1 and MYSQL_PASSWORD_FILE create the app1 database and user. The image grants that user access to the named database.

Create app2 separately

The standard environment variables create one application database and user. Create the second application database and account through an administrative session, then apply tighter grants if the application does not need every privilege:

docker compose up -d db
docker compose exec db mysql -uroot -p

At the password prompt, enter the value stored in secrets/db_root_password.txt. At the MySQL prompt, run SQL similar to:

CREATE DATABASE app2;
CREATE USER 'app2'@'%' IDENTIFIED BY 'use-the-app2-secret-value-here';
GRANT ALL PRIVILEGES ON app2.* TO 'app2'@'%';
FLUSH PRIVILEGES;

Use the exact value in app2_password.txt, and do not paste that value into a committed SQL file or shell history. For least privilege, replace the broad grant with only the statements your application needs, applied by a controlled migration process. The account should not be able to create or drop unrelated databases or change MySQL configuration.

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.

Start the stack and verify connectivity

  1. Validate the Compose model: run docker compose config. Check that the services, volume, network and secret file paths resolve correctly.
  2. Start MySQL: run docker compose up -d db. The first start can take time while the data directory is initialized.
  3. Check health: run docker compose ps and wait for the database health status to become healthy.
  4. Create app2: perform the one-time administrative SQL shown above.
  5. Start applications: run docker compose up -d app1 app2. Applications must retry connections because container start order does not mean MySQL is ready to accept queries.
  6. Inspect failures without printing secrets: use docker compose logs db and each application’s logs, checking that no startup script echoes secret contents.

A health check improves observability, but application retry logic remains necessary. A restart, restore or slow first initialization can make the server temporarily unavailable even after containers have been launched.

Keep MySQL private: when to publish port 3306

Do not add ports: to the database service for normal app-to-database traffic. Applications on backend reach db:3306 directly, while the host has no published MySQL listener.

Publish the port only when a host-based administrator, monitoring system or external client must connect. If that requirement exists, make it explicit and restrict the host firewall and MySQL authentication policy:

ports:
  - "127.0.0.1:3306:3306"

Binding to loopback permits local host tools but not remote machines. A remote connection requires a deliberate firewall rule, encrypted transport where appropriate, strong authentication and an operational reason for exposing the service. A temporary administration container on the private network is often safer than leaving 3306 published.

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

Persistence and initialization rules

Named volume (the default choice)

The mysql_data named volume is mounted at /var/lib/mysql. Docker keeps those files outside the container’s writable layer, so removing and recreating the MySQL container does not remove the database files. A named volume is portable across container replacements and requires less host-path permission management.

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.

Managed bind mount (when host control is required)

A bind mount can be appropriate when an operator needs a specific filesystem, storage policy or backup agent to access the files. It requires correct ownership, permissions, SELinux or AppArmor handling where applicable, and a documented host path. Back up a consistent database, not a live directory copied while MySQL is writing, unless the storage and backup method explicitly provide crash consistency.

Choice Portability Host control Permission work Backup integration
Named volume Good for Compose-managed replacements Lower; Docker manages the location Usually lower Requires a volume-aware backup procedure or logical dump
Bind mount Tied to the selected host path High; host tools can address the path Higher; ownership and security labels matter Can fit host backup tooling, but consistency must be managed

Initialization scripts run only on an empty directory

SQL or shell files mounted into /docker-entrypoint-initdb.d/ run after a fresh database is created. They do not run when /var/lib/mysql already contains a database. Changing MYSQL_DATABASE, MYSQL_USER or password variables later therefore does not rewrite existing data or credentials.

Use initialization files for first-boot setup only. Use versioned schema migrations for tables, indexes, grants and other changes after deployment. If a password must be rotated, alter the existing account deliberately and update the application secret in a controlled sequence; recreating the container with new environment values is not a rotation mechanism.

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

One shared instance or one instance per app?

Factor One shared MySQL container Separate MySQL instances
Isolation Separate databases and users, but a server-level failure affects all apps Stronger server and configuration isolation
Operational overhead One patching, monitoring and backup schedule More containers, upgrades, health checks and administration
Backup scope Backups can cover the whole instance or selected databases Each instance has an independent backup set
Resource use Shared memory and processes; generally more efficient for small apps Higher baseline CPU, memory and storage use
Failure blast radius MySQL outage or bad server change can stop every app A failure is more likely to affect one app
Migration complexity Cross-app server changes need coordination Per-app upgrades are more independent, but multiply the work

Choose a shared instance when the applications are managed together and database-level separation is sufficient. Choose separate instances when regulatory boundaries, incompatible MySQL settings, independent maintenance windows or strong failure isolation outweigh the extra operational cost.

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

Compose secrets versus an external secrets manager

Factor Compose file secrets External secrets manager
Deployment scope Simple for one host or a small Compose deployment Designed for centralized or multi-environment delivery
Rotation Requires replacing secret files and restarting or reconfiguring consumers Can provide managed rotation and coordinated retrieval, depending on the platform
Auditability Mostly depends on host filesystem and deployment controls Usually provides access logs, policies and identity-based permissions
Operational complexity Low; Docker mounts files under /run/secrets/ Higher; requires a service, identities, policies and integration

Compose secrets are a substantial improvement over committed passwords: Docker mounts each secret as a file and grants it only to services listed in that service’s secrets section. For larger environments or frequent rotation, an external manager may provide stronger audit and lifecycle controls.

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.

Backups and recovery

A persistent volume is not a backup. Schedule logical dumps with mysqldump or an equivalent MySQL-supported backup method outside the database container, store copies on durable storage, restrict access to them and encrypt them according to your organization’s policy. Keep enough history to recover from accidental deletion as well as hardware loss.

Document which databases are included, where the files are stored, who can restore them and how credentials are supplied during recovery. Perform restoration exercises: start an isolated MySQL instance, restore a recent backup, verify tables and application queries, and record the elapsed recovery time. The official mechanisms do not define a universal recovery-time objective or recovery-point objective; set those targets from each application’s business requirements.

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

Troubleshooting common failures

“Unknown host db” or connection refused

  • Confirm the application and db share the backend network.
  • Use db, not localhost. Inside an application container, localhost refers to that application container.
  • Check docker compose ps and wait for the health check.
  • Ensure the application retries while MySQL initializes.

Authentication fails after changing a password file

The image reads initialization variables only when the data directory is first created. Change the existing MySQL account explicitly with ALTER USER, then update the application secret and restart the application. Do not delete the volume merely to force initialization unless all data has been backed up and intentional destruction is acceptable.

The app2 database or user does not exist

The shown environment variables automatically create app1 only. Run the one-time SQL for app2, verify with SHOW DATABASES; and SELECT User, Host FROM mysql.user;, and confirm that the application uses the same database name and secret file.

The container was recreated and data disappeared

Inspect docker volume ls and docker compose config. Verify that the service still mounts the same named volume at /var/lib/mysql. A container writable layer, an accidentally changed project name or an unplanned volume removal can result in an apparently empty database.

A secret appears in logs or process output

Remove shell tracing, password-bearing command arguments and startup messages that print environment variables. Prefer password prompts, mounted files and application-specific secret APIs. Rotate any credential that may have been exposed, then review who could read the logs.

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

Production checklist

  • MySQL data is mounted at /var/lib/mysql on a named volume or documented managed bind mount.
  • Applications use db:3306 over a private network and do not use root.
  • Port 3306 is unpublished unless a documented client requires it.
  • Passwords are in protected secret files or an approved external secret manager, not in committed Compose files, Dockerfiles or source code.
  • Every app has its own database and account, with grants narrower than server-wide administration.
  • Initialization scripts are treated as first-boot setup; ongoing changes use versioned migrations.
  • Applications retry until the MySQL health check passes.
  • Backups run outside the database container, are stored durably and have been restored successfully in a test.
  • Secret rotation, MySQL upgrades and volume recovery have written procedures.

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.