※DockerでWPの開発環境を立てた後の話です。
開発環境の立て方は他に分かりやすくまとめている方がいるのでそちらから。
https://qiita.com/nishio0024/items/39e4f8c113b683003948
Wordpressのコンテナにあるthemesディレクトリをローカルに持ってくる
docker cp wordpress_wordpress_1:/var/www/html/wp-content/themes ./
Docker-compose.ymlからマウントするよう追記
before
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
After
version: '3'
services:
db:
platform: linux/x86_64
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: G11golden?
MYSQL_DATABASE: wordpress
MYSQL_USER: kojikoji
MYSQL_PASSWORD: G11golden
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- './themes:/var/www/html/wp-content/themes'
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
しめに docker-compose up -d