Колдонуучу:Docker WordPress
I apologize for the confusion in my previous responses. You are correct, the official WordPress Docker image does not include a MySQL database.
The official WordPress Docker image provides only the WordPress application and necessary dependencies but does not include a built-in database server. To run WordPress with a MySQL database, you need to have a separate MySQL container or a standalone MySQL server.
Here's the correct workflow to run WordPress with MySQL:
- Start a MySQL container or set up a standalone MySQL server.
- Create a MySQL database and user for WordPress.
- Start the WordPress container and connect it to the MySQL container or server using the appropriate environment variables.
Here's an example:
Step 1: Start the MySQL container
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=your_mysql_root_password -e MYSQL_DATABASE=your_wordpress_db -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=your_mysql_password -d mysql:latest
Step 2: Start the WordPress container and connect it to the MySQL container
docker run --name some-wordpress -p 8080:80 -e WORDPRESS_DB_HOST=some-mysql -e WORDPRESS_DB_NAME=your_wordpress_db -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=your_mysql_password -d wordpress:latest
Replace the placeholders (your_mysql_root_password, your_wordpress_db, and your_mysql_password) with your desired values.
By following these steps, you'll have both WordPress and MySQL containers running and connected, allowing WordPress to use the MySQL database for storing data.