AWS上的第二个WordPress + MySQL拒绝连接MySQL

时间:2019-01-22 12:05:20

标签: wordpress docker

我很高兴在我的登台网站的docker-compose容器中设置WordPress。像魅力一样工作。

现在我准备创建生产版本,因此我复制了docker-compose文件,并使用不同的端口和不同的服务名称对其进行了修改。

但是,当我大量运行时,WordPress容器不断重启并抛出错误:

MySQL Connection Error: (2002) Connection refused

Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22

我不太确定为什么不连接,我在做与其他Docker容器完全相同的事情:

c63395d420dc        wordpress:latest    "docker-entrypoint.s…"   3 minutes ago       Up 10 seconds       0.0.0.0:8003->80/tcp                  foo-wp-prod
d58eeeede519        mysql:5.7           "docker-entrypoint.s…"   3 minutes ago       Up 3 minutes        33060/tcp, 127.0.0.1:3310->3306/tcp   foo-wp-db-prod
b6054525bbd9        wordpress:latest    "docker-entrypoint.s…"   5 weeks ago         Up 1 second         0.0.0.0:8001->80/tcp                  foo-wp-staging
e25c3d185152        mysql:5.7           "docker-entrypoint.s…"   6 weeks ago         Up 7 seconds        127.0.0.1:3306->3306/tcp, 33060/tcp   foo-wp-db-staging

我在这里有docker-compose文件:

version: '3.3'

services:
  db_prod:
    image: mysql:5.7
    container_name: foo-wp-db-prod
    volumes:
      - db_data_prod:/var/lib/mysql
    ports:
      - 127.0.0.1:3310:3306
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: -------
      MYSQL_DATABASE: -----
      MYSQL_USER: ------
      MYSQL_PASSWORD: --------

  wordpress_prod:
    depends_on:
      - db_prod
    image: wordpress:latest
    container_name: foo-wp-prod
    ports:
      - "8003:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db_prod:3310
      WORDPRESS_DB_USER: -----
      WORDPRESS_DB_PASSWORD: -----
      WORDPRESS_DB_NAME: -----
    volumes:
      - /home/ubuntu/git/prod/wp-content/themes/foo_theme:/var/www/html/wp-content/themes/foo_theme
      - /home/ubuntu/git/prod/wp-content/uploads:/var/www/html/wp-content/uploads

volumes:
    db_data_prod:

数据库在那里,用户在那里,我可以远程连接到它,所以看来这2个容器之间的连接不适用于此有效安装程序副本。

有人知道发生了什么事吗?

托管环境

AWS VPS
1 GB RAM
Ubuntu(最新)

0 个答案:

没有答案