Mysql
 sql >> Database >  >> RDS >> Mysql

Spostamento del sito Wordpress su Docker:errore durante la creazione della connessione DB

Con la nuova versione di docker-compose apparirà così (se non vuoi usare PhpMyAdmin puoi ometterlo):

version: '3.7'

volumes:
  wp-data:
networks:
  wp-back:

services:

  db:
    image: mysql:5.7
    volumes:
      - wp-data:/var/lib/mysql
    environment:
       MYSQL_ROOT_PASSWORD: rootPassword
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wp-user
       MYSQL_PASSWORD: wp-pass
    ports:
      - 8889:3306
    networks:
      - wp-back

  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    environment:
      PMA_HOST: db
      MYSQL_USER: wp-user
      MYSQL_PASSWORD: wp-pass
      MYSQL_ROOT_PASSWORD: rootPassword
    ports:
      - 3001:80
    networks:
      - wp-back

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - 8888:80
      - 443:443
    environment:
       WORDPRESS_DB_HOST: db
       WORDPRESS_DB_USER: wp-user
       WORDPRESS_DB_PASSWORD: wp-pass
    volumes:
      - ./wordpress-files:/var/www/html
    container_name: wordpress-site
    networks:
      - wp-back

Il volume del database è un volume denominato wp-data, mentre l'html di wordpress è un bind-mount nella directory corrente ./wordpress-files .