mysql “在Docker Compose中重新安装设置并丢失数据后,如何恢复我的WordPress项目?“

j2cgzkjk  于 2023-10-15  发布在  Mysql
关注(0)|答案(1)|浏览(129)
[artpy@fedora GeekTech]$ docker-compose up
[+] Running 4/4
 ✔ Network geektech_default      Created                                   0.0s 
 ✔ Container geektech-adminer-1  Created                                   0.0s 
 ✔ Container geektech-db-1       Created                                   0.0s 
 ✔ Container geektech-wp-1       Created                                   0.0s 
Attaching to geektech-adminer-1, geektech-db-1, geektech-wp-1
geektech-db-1       | 2023-09-21 09:15:19+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.5.20+maria~ubu2004 started.
geektech-adminer-1  | WordPress not found in /var/www/html - copying now...
geektech-wp-1       | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.89.2.13. Set the 'ServerName' directive globally to suppress this message
geektech-wp-1       | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.89.2.13. Set the 'ServerName' directive globally to suppress this message
geektech-wp-1       | [Thu Sep 21 09:15:19.264902 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.56 (Debian) PHP/8.2.6 configured -- resuming normal operations
geektech-wp-1       | [Thu Sep 21 09:15:19.264925 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
geektech-db-1       | 2023-09-21 09:15:19+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
geektech-db-1       | 2023-09-21 09:15:19+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.5.20+maria~ubu2004 started.
geektech-adminer-1  | Complete! WordPress has been successfully copied to /var/www/html
geektech-adminer-1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.89.2.11. Set the 'ServerName' directive globally to suppress this message
geektech-adminer-1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.89.2.11. Set the 'ServerName' directive globally to suppress this message
geektech-adminer-1  | [Thu Sep 21 09:15:19.378429 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.56 (Debian) PHP/8.2.6 configured -- resuming normal operations
geektech-adminer-1  | [Thu Sep 21 09:15:19.378454 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
geektech-db-1       | 2023-09-21 09:15:19+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] Starting MariaDB 10.5.20-MariaDB-1:10.5.20+maria~ubu2004 source revision b735ca47738a1d2e995a429f40afd620eb7d8843 as process 1
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Uses event mutexes
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Number of pools: 1
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Using Linux native AIO
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Completed initialization of buffer pool
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=45115,45115
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: 128 rollback segments are active.
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Creating shared tablespace for temporary tables
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: 10.5.20 started; log sequence number 45127; transaction id 20
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] Plugin 'FEEDBACK' is disabled.
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] InnoDB: Buffer pool(s) load completed at 230921  9:15:19
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] Server socket created on IP: '::'.
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] Reading of all Master_info entries succeeded
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] Added new Master_info '' to hash table
geektech-db-1       | 2023-09-21  9:15:19 0 [Note] mysqld: ready for connections.
geektech-db-1       | Version: '10.5.20-MariaDB-1:10.5.20+maria~ubu2004'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution

我有一个WordPress项目,我使用Docker Compose在Podman容器上运行,在过去的一周里,我遇到了Podman和Docker Compose无法启动的问题。我不得不尝试各种解决方案,包括卸载和重新安装Podman和Docker Compose。最终,我通过将Docker Compose的版本降级到以前的版本来解决这个问题。现在,问题是我没有备份我的项目,我执行了一个提交,然后删除并重新安装了Podman卷中的WordPress设置。目前,我的项目无法访问,当我启动Docker Compose时,它试图从头开始重新安装WordPress,导致项目为空。
如何恢复我的项目?

cetgtptt

cetgtptt1#

你没有像医生说的那样从四维Angular 思考!
首先,请提供您的docker-compose.yml代码,这样我们就可以更好地了解您的容器化环境是如何部署的。
我看到你有三个集装箱...

✔ Container geektech-adminer-1  Created   0.0s 
 ✔ Container geektech-db-1       Created.  0.0s 
 ✔ Container geektech-wp-1       Created

我的第一个问题是什么是adminer-1容器,这是Podman吗?
好的,这是一个迷你Docker组成101(这可能是你的问题)
1.在包含docker-compose.yml配置的目录中运行docker-compose up,最初将下载/拉取并缓存yml容器中定义的所有图像。
1.因此,每次运行docker-compose up时,都会基于容器块中使用的映像构建容器和卷。
1.如果您开始处理您的环境,一般安装和本地数据输入到您的运行容器中,这些数据都存储在运行容器中。
1.如果在docker-compose.yml目录下运行docker-compose stop,这将关闭运行环境,Docker Desktop中当前缓存的此容器组的任何数据仍将存在。然后,您可以运行docker-compose up命令,所有输入的数据仍然与上次使用docker-compose stop时一样。
1.但是,如果您在项目目录中使用docker-compose down命令,这将关闭docker-compose.yml中所有正在运行的容器,然后完全删除Docker Desktop App中所有容器缓存的数据。所以下次你使用docker-compose up时...您将再次回到起点(所有数据丢失)。
1.要从Docker部署的容器中保留数据,您需要持久化数据。您需要将卷数据从容器映像Map到包含docker-compose.yml文件的项目目录。请参阅以下yml卷持久Map配置的示例.

容器中的持久卷

因此,在容器块中的docker-compose.yml中,添加卷配置以将当前图像数据Map到合成文件的目录。请参阅下面的例子为WordPress的图像在撰写文件.

version: '3.8'

services:

  # here is our mariadb container
  # https://hub.docker.com/_/mariadb
  db:
    image: mariadb:11.0.2
    restart: always
    ports:
      - "3306:3306"
    volumes:
      # our persistent volume database mapping
      - ./db:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

  # here is our wordpress container
  # https://hub.docker.com/_/wordpress
  wordpress:
    image: wordpress:latest
    restart: always
    ports:
      - "80:80"
    depends_on:
      - db
    volumes:
      # our persistent volume sub directories mapping
      - ./themes:/var/www/html/wp-content/themes
      - ./mu-plugins:/var/www/html/wp-content/mu-plugins
      - ./plugins:/var/www/html/wp-content/plugins
      - ./uploads:/var/www/html/wp-content/uploads
    environment:

      # our docker wp config settings
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress

      # our docker wp config extra php defines
      WORDPRESS_CONFIG_EXTRA: |

        /** disable wp core auto update */
        define('WP_AUTO_UPDATE_CORE', false);

请参阅我的repo on github,了解Docker Compose与WordPress的用法,这可能有助于将持久数据和其他集成到docker-compose.yml文件中。

相关问题