version: '3'
services:
wordpress:
depends_on:
– mysql
image: wordpress:latest
links:
– mysql:mysql
ports:
– 80:80
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_USER: root
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_PASSWORD: root
MYSQL_PORT_3306_TCP: 3306
restart: unless-stopped
networks:
– my-bridge
mysql:
image: mysql:8
command: '–default-authentication-plugin=mysql_native_password'
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
MYSQL_USER: root
MYSQL_PASSWORD: root
volumes:
– mysql-data:/var/lib/mysql
restart: unless-stopped
networks:
– my-bridge
ports:
– "3306:3306"
volumes:
mysql-data:
networks:
my-bridge:
driver: bridge
原文链接:https://blog.csdn.net/zsy135220/article/details/84364429?ops_request_misc=&request_id=f9be889009634066a9778e49e56ea8bd&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-24-84364429-null-null.268%5Ev1%5Econtrol&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81