Macで幸せにDocker生活していた人が、Windows環境で絶望に突き落とされた解決できなかったトラブル集です。つらい。
docker-compose が WSL 上で立てた Docker で動かない
最近、WSL上でもDockerが動くようになりました。
ネットワーク回りのトラブルでWSL上に立てたDockerではdocker-composeが動きません。
$ docker-compose up -d
Creating network "etl_default" with the default driver
ERROR: Failed to Setup IP tables: Unable to enable NAT rule: (iptables failed: iptables --wait -t nat -I POSTROUTING -s {ip}/16 ! -o br-e9ec09beb9a3 -j MASQUERADE: iptables: No chain/target/match by that name.
(exit status 1))
つらい(◞‸◟) Microsoftさんもうちょっと頑張って……。
WSL上からdocker-compose叩くとパスが違ってつらい
WSL上のDockerがつらいので、Windows上のDockerにWSLから繋ぎます。(参考: Bash on Ubuntu on Windowsからdocker-machineにTLSで接続する(Hyper-V使用))
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/mnt/c/Users/Kage/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fc27365a8322 *************_nginx "nginx -g 'daemon ..." 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp *******_nginx
fdb099696d3c *************_web "docker-php-entryp..." 4 minutes ago Up 4 minutes 9000/tcp *******_web
85ca308d5037 memcached:1.4 "docker-entrypoint..." 4 minutes ago Up 4 minutes 11211/tcp *******_memcached
7ab615fffb35 postgres:latest "docker-entrypoint..." 5 months ago Up 19 minutes 0.0.0.0:5432->5432/tcp chat-app-server_db_1
9b11b5a7fabc adminer "entrypoint.sh doc..." 5 months ago Up 19 minutes 0.0.0.0:8080->8080/tcp chat-app-server_adminer_1
おっしゃ。
> docker-compose up --build
Recreating dog_apache_1 ... done
Attaching to dog_apache_1
apache_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.2. Set the 'ServerName' directive globally to suppress this message
apache_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.2. Set the 'ServerName' directive globally to suppress this message
apache_1 | [Mon Dec 03 14:31:36.318825 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.12 configured -- resuming normal operations
apache_1 | [Mon Dec 03 14:31:36.319066 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
apache_1 | [Mon Dec 03 14:31:38.734628 2018] [autoindex:error] [pid 17] [client 192.168.99.1:49345] AH01276: Cannot serve directory /var/www/html/dog/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
apache_1 | 192.168.99.1 - - [03/Dec/2018:14:31:38 +0000] "GET /dog/ HTTP/1.1" 403 510 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0"
Windows上のパス(/c/Users/Kage/src/dog
)とWSL上のパス(/mnt/c/Users/Kage/src/dog
)が違っててつらい……
ルートに/c
でマウントすれば動くかもしれないけど、WSLこれ以上壊したくないので試してません。
ちなみに、Docker Quickstart Terminal上から叩くと上手く動きました。
Windows10 HomeではDocker for Windowsが使えない
Hyper-VがWindows10 Proでないと使えないのでDocker Toolboxを使ってVirtualBox上に立てることになります。
VirtualBoxなので仮想環境の上にDockerを立てることになり重いです、Hyper-Vのためだけに1万出すのはつらい(つд⊂)
ファイルシステム周りのせいでマウントディレクトリにアクセスすると落ちる(ことがある)
$ docker-compose up --build
Creating *************_mysql_1 ... done
Creating *******_web ... done
Creating *******_nginx ... done
Creating *******_memcached ...
Creating *************_mysql_1 ...
Creating *******_supervisord ...
Creating *******_web ...
Creating *******_nginx ...
Attaching to *************_data_1, *******_memcached, *************_mysql_1, *******_supervisord, *******_web, *******_nginx
mysql_1 | Initializing database
*******_supervisord | /usr/lib/python2.7/dist-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
*******_supervisord | 'Supervisord is running as root and it is searching '
*******_web | [03-Dec-2018 12:08:56] NOTICE: fpm is running, pid 1
*******_supervisord | Error: The directory named as part of the path /var/www/html/application/logs/supervisor.log does not exist.
*******_supervisord | For help, use /usr/bin/supervisord -h
*************_data_1 exited with code 0
*******_supervisord exited with code 2
mysql_1 | 2018-12-03T12:08:55.567590Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql_1 | 2018-12-03T12:08:55.585417Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
mysql_1 | 2018-12-03T12:08:56.585219Z 0 [ERROR] InnoDB: Operating system error number 22 in a file operation.
mysql_1 | 2018-12-03T12:08:56.585462Z 0 [ERROR] InnoDB: Error number 22 means 'Invalid argument'
mysql_1 | 2018-12-03T12:08:56.585741Z 0 [ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. Cannot continue operation
mysql_1 | 2018-12-03T12:08:56.585876Z 0 [ERROR] InnoDB: Cannot continue operation.
*************_mysql_1 exited with code 3
いろいろ試しましたがこればかりはどうしようもなかったです。つらい( ˘•ω•˘ )
対応策
素直に Ubuntu と Windows のデュアルブートにしました。しあわせ