AWS Lightail Ubuntu 18.04服务器上的Docker mysql 5.7继续重启

时间:2019-01-07 04:38:39

标签: mysql wordpress docker ubuntu-server amazon-lightsail

我有一个脚本将ubuntu服务器上的docker wordpress和mysql服务器一起安装。此脚本在本地计算机上的VMWare上的ubuntu服务器16.04和18.04上均可正常运行。此脚本适用于AwS lightail ubuntu服务器16.04实例,但不适用于18.04。我在脚本命令上没有任何错误。整个过程成功完成,但是当我检查运行容器时,我看到mysql容器正在重新启动。这仅在AWS lightail ubuntu 18.04实例上发生。不知道为什么。有人可以帮忙吗?脚本如下:

#!/bin/bash
apt-get -y update
apt-get -y install apt-transport-https ca-certificates curl software- 
properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] 
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get -y update
apt-get -y install docker-ce docker-compose

mkdir wordpress
cd wordpress

echo "file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 600" >> uploads.ini

echo "version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: user
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: user123

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "80:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: user123
     volumes:
       - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
volumes:
    db_data: {}" >> docker-compose.yml

docker-compose up -d --build

1 个答案:

答案 0 :(得分:0)

我在数据库环境中发现了WORDPRESS_DB_HOST问题:db:3306。我把我的yml脚本降低到基本最低要求,并且有效。我也认为mysql与AWS Lightail ubuntu 18.04服务器存在问题。 Mariadb正常运行。我在AWS lightail ubuntu服务器18.04上最终的docker-compose.yml脚本是:

wordpress:
  image: wordpress
  links:
    - wordpress_db:mysql
  ports:
    - 80:80
  volumes:
    - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
wordpress_db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: user123