wordpress:cli
コンテナーは、コンテナーと共有されているボリューム上のファイルを操作できませんwordpress
。
docker-compose.yml
WordPressのブートストラップに使用するファイルは次のとおりです。
version: "3"
services:
wordpress:
image: wordpress
ports: ["80:80"]
volumes: ["wp_test:/var/www/html"]
environment:
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: secret
mysql:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: secret
cli:
image: wordpress:cli
volumes: ["wp_test:/var/www/html"]
command: sh -c "sleep 20 && wp core install --path=/var/www/html --url=localhost --title=test --admin_user=test --admin_password=test --admin_email=test@example.com"
volumes:
wp_test:
インストールを開始するとdocker-compose up
、wp-cli
次の警告が表示されます。
cli_1 | Warning: Unable to create directory wp-content/uploads/2018/02. Is its parent directory writable by the server?
wp-cli
インストールはこれまでのところうまくいきますが、他のタスクではファイルの操作が重要であるため、この警告を修正したいと思います。
コンテナ内からwordpress
、権限は次のようになります。
drwxr-xr-x 5 www-data www-data 4096 Feb 2 11:21 .
drwxr-xr-x 4 root root 4096 Jan 4 01:30 ..
-rw-r--r-- 1 www-data www-data 234 Feb 2 11:21 .htaccess
-rw-r--r-- 1 www-data www-data 418 Sep 25 2013 index.php
-rw-r--r-- 1 www-data www-data 19935 Jan 6 19:32 license.txt
-rw-r--r-- 1 www-data www-data 7413 Dec 12 2016 readme.html
-rw-r--r-- 1 www-data www-data 5434 Sep 23 12:21 wp-activate.php
drwxr-xr-x 9 www-data www-data 4096 Jan 16 21:39 wp-admin
-rw-r--r-- 1 www-data www-data 364 Dec 19 2015 wp-blog-header.php
-rw-r--r-- 1 www-data www-data 1627 Aug 29 2016 wp-comments-post.php
-rw-r--r-- 1 www-data www-data 2764 Feb 2 11:21 wp-config-sample.php
-rw-r--r-- 1 www-data www-data 3144 Feb 2 11:21 wp-config.php
drwxr-xr-x 4 www-data www-data 4096 Feb 2 11:22 wp-content
-rw-r--r-- 1 www-data www-data 3669 Aug 20 04:37 wp-cron.php
drwxr-xr-x 18 www-data www-data 12288 Jan 16 21:39 wp-includes
-rw-r--r-- 1 www-data www-data 2422 Nov 21 2016 wp-links-opml.php
-rw-r--r-- 1 www-data www-data 3306 Aug 22 11:52 wp-load.php
-rw-r--r-- 1 www-data www-data 36583 Oct 13 02:10 wp-login.php
-rw-r--r-- 1 www-data www-data 8048 Jan 11 2017 wp-mail.php
-rw-r--r-- 1 www-data www-data 16246 Oct 4 00:20 wp-settings.php
-rw-r--r-- 1 www-data www-data 30071 Oct 18 17:36 wp-signup.php
-rw-r--r-- 1 www-data www-data 4620 Oct 23 22:12 wp-trackback.php
-rw-r--r-- 1 www-data www-data 3065 Aug 31 2016 xmlrpc.php
しかし、cli
コンテナー内からは、同じボリュームは次のようになります。
drwxr-xr-x 5 www-data www-data 4096 Feb 2 11:21 .
drwxr-xr-x 3 root root 4096 Jan 10 07:36 ..
-rw-r--r-- 1 xfs xfs 234 Feb 2 11:21 .htaccess
-rw-r--r-- 1 xfs xfs 418 Sep 25 2013 index.php
-rw-r--r-- 1 xfs xfs 19935 Jan 6 19:32 license.txt
-rw-r--r-- 1 xfs xfs 7413 Dec 12 2016 readme.html
-rw-r--r-- 1 xfs xfs 5434 Sep 23 12:21 wp-activate.php
drwxr-xr-x 9 xfs xfs 4096 Jan 16 21:39 wp-admin
-rw-r--r-- 1 xfs xfs 364 Dec 19 2015 wp-blog-header.php
-rw-r--r-- 1 xfs xfs 1627 Aug 29 2016 wp-comments-post.php
-rw-r--r-- 1 xfs xfs 2764 Feb 2 11:21 wp-config-sample.php
-rw-r--r-- 1 xfs xfs 3144 Feb 2 11:21 wp-config.php
drwxr-xr-x 4 xfs xfs 4096 Feb 2 11:22 wp-content
-rw-r--r-- 1 xfs xfs 3669 Aug 20 04:37 wp-cron.php
drwxr-xr-x 18 xfs xfs 12288 Jan 16 21:39 wp-includes
-rw-r--r-- 1 xfs xfs 2422 Nov 21 2016 wp-links-opml.php
-rw-r--r-- 1 xfs xfs 3306 Aug 22 11:52 wp-load.php
-rw-r--r-- 1 xfs xfs 36583 Oct 13 02:10 wp-login.php
-rw-r--r-- 1 xfs xfs 8048 Jan 11 2017 wp-mail.php
-rw-r--r-- 1 xfs xfs 16246 Oct 4 00:20 wp-settings.php
-rw-r--r-- 1 xfs xfs 30071 Oct 18 17:36 wp-signup.php
-rw-r--r-- 1 xfs xfs 4620 Oct 23 22:12 wp-trackback.php
-rw-r--r-- 1 xfs xfs 3065 Aug 31 2016 xmlrpc.php
コンテナ内のユーザーcli
は(コンテナ内にあるのとwww-data
同じようにwordpress
)、目的のフォルダーを作成できません。
$ mkdir -p wp-content/uploads/2018/02
mkdir: can't create directory 'wp-content/uploads/': Permission denied
Macでdocker compose 1.18.0とdocker engine 17.12.0-ceを実行しています。
github issueも作成しました。