0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Docker composeでWordpressの開発環境を立てた後にコンテナ側のthemesディレクトリをローカルに反映した後マウントする

Posted at

※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

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?