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

When a WordPress or MySQL container stops, its main process has exited or Docker is repeatedly restarting it. The exit reason is in the container state and logs. Start there before changing passwords, deleting volumes, or adding restart policies:

docker compose ps -a
docker compose logs --tail=200 wordpress db
docker inspect CONTAINER

Most WordPress-on-Compose failures come from one of four conditions: WordPress is using the wrong database host, its database name or credentials do not match MySQL, MySQL is still initializing when WordPress connects, or the data volume, entrypoint, permissions, or host resources are failing. The sections below identify the exact symptom and the least-destructive fix.

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

What a stopped container actually means

A container stays alive only while its primary process (PID 1) is running. If that process exits, Docker reports the container as Exited. A process that repeatedly fails can produce Restarting, while a healthy service remains Up and may show a health status. These states are different problems:

  • Exited with an error: the command, entrypoint, mounted file, permissions, configuration, or application failed.
  • Exited with code 0: the command completed normally. This is expected for a migration, import, backup, or other one-shot job, but not for a database or web service.
  • Restarting: Docker is relaunching a process that keeps failing. The final line often only says that a restart occurred; the first fatal log line explains why.
  • Up but unhealthy: the process is running, but its health check cannot reach the service or complete its test.

Do not treat docker compose start as a repair command. Docker documents that “The docker compose start command is useful only to restart containers that were previously created but were stopped.” It does not recreate a changed service definition or correct a failing command.

#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: 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.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

The diagnostic sequence that prevents guesswork

1. Check every service, including stopped containers

docker compose ps -a

Look specifically at the wordpress and db rows. Record whether either service is Exited, Restarting, Up, or healthy. If the service names differ in your file, use those names in every subsequent command.

2. Read the beginning of the failure, not the restart loop

docker compose logs --tail=200 wordpress db

Compose follows both services when you run docker compose up without detaching, so the same output is available during startup. For a single container, use docker logs CONTAINER. Find the first fatal message: a refused connection, unknown database, access denial, missing file, permission error, corrupted data directory, failed command, or out-of-memory termination. A later line such as “restarting” is only a consequence.

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

3. Inspect the exit code and state fields

docker inspect --format '{{.State.Status}} exit={{.State.ExitCode}} oom={{.State.OOMKilled}} error={{.State.Error}}' CONTAINER

Replace CONTAINER with the name or ID shown by docker compose ps -a. An out-of-memory kill requires reducing the workload or giving the Docker host more memory. A nonzero exit caused by an invalid command, missing file, or permission problem needs a configuration or mount fix instead. If the state says the process exited successfully, inspect the command: it may be an intentional one-shot task that should not have a restart policy.

4. Verify the effective configuration

docker compose config

This renders variables and merges Compose files, making it easier to spot an empty value, a misspelled service, or a volume mounted at the wrong path. Do not publish the output if it contains passwords or other secrets.

5. Classify the failure before changing data

Keep a copy of the relevant log lines and state output. Restarting or recreating a container can obscure the original message. Never remove a database volume during this phase unless data destruction is intentional and a verified backup exists.

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

Make WordPress use the MySQL service that actually exists

Inside a Compose network, containers reach one another through the Compose service name. If the database service is named db, WordPress should use db (optionally with the MySQL port), not localhost. In the WordPress container, localhost means the WordPress container itself, where no MySQL server is listening.

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.
WordPress setting MySQL setting What must match
WORDPRESS_DB_HOST Compose service name Use the database service DNS name, commonly db; add :3306 when specifying the port explicitly.
WORDPRESS_DB_USER MYSQL_USER The application username must be the same.
WORDPRESS_DB_PASSWORD MYSQL_PASSWORD The password must be the same, including capitalization and punctuation.
WORDPRESS_DB_NAME MYSQL_DATABASE The database name must match an existing database on the MySQL server.

Both services also need to be attached to the same Compose network. A custom networks section is fine, but attaching only one service to it prevents DNS and TCP connectivity. Check the rendered configuration and, when necessary, inspect network membership with docker network inspect NETWORK.

The database must already exist

The WordPress image connects to MySQL; it does not create an arbitrary database named in WORDPRESS_DB_NAME. MySQL creates the database during first-time initialization when MYSQL_DATABASE is supplied. If that initialization never ran, or the requested name differs, WordPress reports an error establishing a database connection.

Environment variables that create the initial database and user are not a migration mechanism. Once /var/lib/mysql contains an initialized data directory, changing MYSQL_DATABASE, MYSQL_USER, or MYSQL_PASSWORD in Compose generally does not rewrite existing accounts or create a new database. Inspect the actual server instead of assuming an edited Compose file changed it:

docker compose exec db mysql -uroot -p
SHOW DATABASES;
SELECT User, Host FROM mysql.user;

Enter the root password when prompted. If the expected database or user is absent, create or alter it deliberately on the existing data directory, or restore a known-good backup. Do not delete the volume simply to make an environment variable take effect unless the data is disposable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【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.

Account for MySQL’s asynchronous initialization

On a new data directory, the MySQL entrypoint initializes system tables, applies initialization scripts, creates requested databases and users, and only then accepts normal client connections. WordPress can start first and receive “connection refused” even though the MySQL container is still working normally.

Keep the stack running while the initialization log finishes. If WordPress cannot tolerate a transient refusal, coordinate startup with a health check and a dependency condition, or use an application-side retry loop. The MySQL image documentation notes that when an application does not handle MySQL downtime or waiting gracefully, “putting a connect-retry loop before the service starts might be necessary.”

A Compose pattern with a health check

services:
  db:
    image: mysql
    restart: always
    environment:
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    volumes:
      - db_data:/var/lib/mysql
    healthcheck:
      test: ['CMD-SHELL', 'mysqladmin ping -h localhost -u root -p$${MYSQL_ROOT_PASSWORD}']
      interval: 5s
      timeout: 5s
      retries: 20

  wordpress:
    image: wordpress
    restart: always
    depends_on:
      db:
        condition: service_healthy
    ports:
      - '8080:80'
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: ${MYSQL_USER}
      WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
      WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
    volumes:
      - wp_data:/var/www/html

volumes:
  db_data:
  wp_data:

This is a pattern, not a production secret set. Supply the interpolation variables securely, pin image tags that you have tested, and adjust the health-check timing for the size of the database and the speed of the host. A health check delays dependent startup; it does not repair invalid credentials, a missing database, damaged files, or an entrypoint that cannot run.

Keep the data when containers are recreated

Containers are replaceable. The MySQL data directory and WordPress files must be persistent:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Mount a named volume at /var/lib/mysql (or the data path used by the selected MySQL image).
  • Mount a separate named volume at /var/www/html for WordPress core files, themes, plugins, and uploads.
  • Use host bind mounts only when you understand their ownership, permissions, backup, and portability implications.

List the volumes and their mount points with:

docker volume ls
docker inspect CONTAINER

Recreating a MySQL container without its data volume can remove the initialized database and make the next start look like a fresh installation. Recreating WordPress without its content volume can remove uploads, themes, and plugins. A normal docker compose down removes containers and networks but leaves named volumes; docker compose down -v also removes the declared volumes and is destructive.

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.

Back up before destructive troubleshooting

Before removing or reinitializing a volume, take a database-consistent dump or restore a verified backup and confirm that it can be read. A filesystem copy made while MySQL is writing may not be a consistent backup. If you have no backup and the old volume still exists, preserve it and work on a copy or a new test stack rather than experimenting on the only data.

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

Fix the failure that the logs identify

Wrong host name or network

Change WORDPRESS_DB_HOST from localhost or an obsolete container name to the current Compose service name, commonly db. Make sure both services share a network and that the database listens on the network interface used by the image. Recreate the affected service after changing its definition:

docker compose up -d --force-recreate wordpress

A connection refusal while MySQL is still initializing is a timing problem; a refusal after MySQL reports readiness usually indicates the host, port, network, or server process is wrong.

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.

Credentials or database name do not match

Compare the four WordPress variables with the values that were used when the MySQL data directory was first initialized. If the directory is old, a changed Compose environment value may have no effect. Use the MySQL client to check the database and account, then alter the account or update WordPress deliberately. Avoid repeatedly changing passwords in the file while leaving an old data directory in place; that produces a restart loop without changing the stored credentials.

MySQL initialization is incomplete

Read the database log until initialization has either completed or stopped on a fatal error. Keep the stack up during a normal initialization. If it fails on an initialization script, invalid option, or permissions issue, correct that first. A health check and dependency condition prevent WordPress from being launched before MySQL is ready, but they cannot make a failed initialization succeed.

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.

Entrypoint, mount, or permission error

Messages about a missing command, missing configuration file, read-only path, or permission denial usually come from a custom command, entrypoint, bind mount, or file ownership mismatch. Temporarily run the image with the default command and without the custom mount to isolate the change. Then restore one customization at a time, checking ownership and the path expected by the image. Do not hide the error by adding a restart policy.

Out-of-memory termination

If docker inspect reports OOMKilled: true, or host metrics show memory exhaustion, reduce concurrent work or allocate more memory to Docker and the host. A restart policy will repeatedly relaunch the same workload and can make diagnosis harder while the memory limit remains insufficient.

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

An intentional one-shot command

Migration, import, backup, and command-line jobs are supposed to exit after completing. Do not attach restart: always to those services. If a web or database service exits with code 0, inspect its command and entrypoint for an accidental one-shot override.

Use restart policies only after the root cause is fixed

restart: always is useful for services that should return after a crash or host reboot. It improves recovery after a transient failure, but it cannot repair bad credentials, a nonexistent database, corrupted data, a broken entrypoint, or an out-of-memory condition. With an unresolved error, it creates an opaque restart loop.

During diagnosis, temporarily remove or disable the restart policy so the failed container remains available for inspection, or stop the loop and run the service in the foreground:

docker compose stop wordpress db
docker compose up wordpress db

After the logs show a successful startup, re-enable the policy and verify that both services remain up through a normal restart.

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

A safe recovery procedure

  1. Capture evidence. Save docker compose ps -a, the last 200 log lines for both services, and the inspected state, including the exit code and OOM flag.
  2. Render the configuration. Run docker compose config and check service names, interpolated variables, networks, commands, and volume paths.
  3. Fix configuration without deleting data. Correct the host name, credentials, database name, command, mount, or resource limit identified by the first fatal log line.
  4. Start in the foreground. Use docker compose up wordpress db and watch MySQL initialization and WordPress connection attempts together.
  5. Confirm readiness. Run docker compose ps; the database should be running and healthy when a health check is configured, and WordPress should remain running.
  6. Test the application. Open the mapped WordPress port, complete a harmless page request, and verify that uploads and the administration area still work.
  7. Re-enable recovery. Apply restart: always only to long-running services, then recreate them with docker compose up -d.
  8. Reset only disposable data. If the stack is a throwaway development install and no data is needed, docker compose down -v removes the named volumes so MySQL can initialize from scratch. Never use this step as a first-line fix on a valuable site.

Final verification checklist

  • docker compose ps -a shows both services running rather than restarting or exited.
  • The WordPress database host is the Compose service name, not localhost.
  • The database name, user, and password correspond to the accounts and database that actually exist in MySQL.
  • MySQL logs show initialization completed, or the existing data directory opened successfully.
  • WordPress and MySQL share a network.
  • A named volume persists /var/lib/mysql.
  • A separate named volume persists /var/www/html.
  • No out-of-memory kill, entrypoint error, missing file, or permission denial remains in the logs.
  • Restart policies are applied only to services intended to run continuously.
  • A tested backup exists before any volume reset or database repair.

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.