aws lightsail ubuntu 18.04服务器上的docker mysql 5.7继续重启

nwlqm0z1  于 2021-06-15  发布在  Mysql
关注(0)|答案(1)|浏览(357)

我有一个脚本安装DockerWordPress和mysql服务器在ubuntu服务器上。这个脚本在我的本地机器上的ubuntu服务器16.04和vmware服务器18.04上都可以正常工作。同样的脚本也适用于aws lightsail ubuntu server 16.04示例,但不适用于18.04。脚本命令没有任何错误。整个过程成功完成,但当我检查runnign容器时,我看到mysql容器正在重新启动。这只发生在aws lightsail 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
cedebl8k

cedebl8k1#

我在db环境中发现了wordpress\u db\u host:db:3306的问题。我把我的yml脚本降到最低限度,它工作了。我还认为mysql与aws lightsail Ubuntu18.04服务器有问题。mariadb工作得很好。我在aws lightsail ubuntu server 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

相关问题