简体   繁体   English

docker-composer wordpress 在我重新启动时询问安装

[英]docker-composer wordpress asks installation whenever I reboot

Everything is fine until I reboot my Ubuntu host.一切都很好,直到我重新启动我的 Ubuntu 主机。 After reboot, the WordPress page shows the fresh installation page.重新启动后,WordPress 页面显示全新安装页面。 There are volumes properly mounted on the host's local directory.在主机的本地目录上正确安装了卷。

I only have set docker.service to restart the Docker service when reboot.我只设置了 docker.service 在重启时重启 Docker 服务。 There must be some mistake I am not aware of.一定有一些我不知道的错误。

At least, what shall I do if this thing happens again?至少,如果这件事再次发生,我该怎么办? I see all the files mounted on my host shows the latest modification time, so it looks like the data is persistent...我看到我主机上挂载的所有文件都显示了最新的修改时间,所以看起来数据是持久的......

(edited) I also tried the external voume as @bilal said in the comment, but it didn't make any difference. (已编辑)我也尝试了@bilal 在评论中所说的外部声音,但没有任何区别。 So, now I am thinking this may be related to the process while booting up.所以,现在我认为这可能与启动时的过程有关。 like, instead of stop&start, it somehow down/up.就像,而不是停止和启动,它以某种方式向下/向上。 But I may be wrong.但我可能错了。

version: '3.8'

services:

  db:
    container_name: $DB_CONTAINER
    image: mariadb:latest
    restart: always
    volumes:
      - wordpress_db_data:/var/lib/mysql:rw
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: 1
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD

  wp:
    container_name: $WP_CONTAINER
    image: wordpress:latest
    depends_on:
      - db
      - cp
    restart: always
    volumes:
      - wordpress_wp_data:/var/www/html:rw
    environment:
      WORDPRESS_DB_HOST: $DB_CONTAINER
      WORDPRESS_DB_NAME: $DB_NAME
      WORDPRESS_DB_USER: $DB_USER
      WORDPRESS_DB_PASSWORD: $DB_PASSWORD
      WORDPRESS_TABLE_PREFIX: $WP_TABLE_PREFIX
      VIRTUAL_HOST: $VIRTUAL_HOST
      VIRTUAL_PORT: $VIRTUAL_PORT
      LETSENCRYPT_HOST: $VIRTUAL_HOST
      LETSENCRYPT_EMAIL: $LETSENCRYPT_EMAIL
      #LETSENCRYPT_TEST: 'true'

  cp:
    build: composer
    container_name: ${COMPOSER_CONTAINER}
    volumes:
      - wordpress_wp_data:/app/wp-content:rw
    command: composer install

networks:
  default:
    external:
      name: nginx_proxy


volumes:
  wordpress_wp_data:
    name: wordpress_wp_data
  wordpress_db_data:
    name: wordpress_db_data

Here's my volume list这是我的卷列表

>  docker volume ls
DRIVER    VOLUME NAME
local     wordpress_db_data
local     wordpress_wp_data

Here's my docker.service这是我的 docker.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes

# kill only the docker process, not all processes in the cgroup
KillMode=process
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target

you should use docker volumes for persistent storage what I understand is you mounted dir.您应该使用 docker 卷进行持久存储,我理解的是您安装的目录。 See docker volumes for more information.有关详细信息,请参阅 docker 卷。

so your volume section should look like this.所以你的音量部分应该是这样的。

volumes:
      - ./wp_data:/var/www/html:rw
      - wp_data:/wp_data{volume you want to persist}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM