laradoc が windows7でなかなか動かん

イシュー

  • laradoc を windows7 で動作させようとするとなかなか苦労する。

参考

mysql 起動時にエラー

mysql_1         | 2018-01-31 10:08:51 1 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
mysql_1         | 2018-01-31 10:08:51 1 [Note] Plugin 'FEDERATED' is disabled.
mysql_1         | mysqld: Table 'mysql.plugin' doesn't exist
mysql_1         | 2018-01-31 10:08:51 1 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
参考
mysql_1         | 2018-01-31 10:18:04 7eff50b38740  InnoDB: Operating system error number 22 in a file operation.
mysql_1         | InnoDB: Error number 22 means 'Invalid argument'.
mysql_1         | InnoDB: Some operating system error numbers are described at
mysql_1         | InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
mysql_1         | 2018-01-31 10:18:04 32 [ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. Cannot continue operation

何がInvalid argumentなの?

  • docker-compose build mysql から見直し
$ docker-compose.exe build mysql
Building mysql
Step 1/10 : ARG MYSQL_VERSION=8.0
Step 2/10 : FROM mysql:${MYSQL_VERSION}
 ---> f008d8ff927d
Step 3/10 : MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
 ---> Using cache
 ---> b56034622b31
Step 4/10 : ARG TZ=UTC
 ---> Using cache
 ---> 77cba3ac311f
Step 5/10 : ENV TZ ${TZ}
 ---> Using cache
 ---> 3d015c3063da
Step 6/10 : RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /et
c/timezone
 ---> Using cache
 ---> aaa7f11e6bd4
Step 7/10 : RUN chown -R mysql:root /var/lib/mysql/
 ---> Using cache
 ---> f9d2ab1e80d1
Step 8/10 : ADD my.cnf /etc/mysql/conf.d/my.cnf
 ---> Using cache
 ---> c85c03c9ad4f
Step 9/10 : CMD ["mysqld"]
 ---> Using cache
 ---> 6be1f98a8fce
Step 10/10 : EXPOSE 3306
 ---> Using cache
 ---> 0c354157ddb1
Successfully built 0c354157ddb1
Successfully tagged reliefdock_mysql:latest
$ docker-compose.exe logs
Attaching to reliefdock_mysql_1
mysql_1         | Initializing database
mysql_1         | 2018-01-31T10:49:22.933229Z 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-01-31T10:49:22.933299Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
mysql_1         | 2018-01-31T10:49:22.943490Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
mysql_1         | 2018-01-31T10:49:22.943837Z 0 [ERROR] Aborting
mysql_1         |

The problem is one of permissions: the container has the data dir /var/lib/mysql owned by root, so when entrypoint.sh is calling mysqld --help to get the data dir, the directory isn't writable by mysqld and mysqld can't write the innodb log files it will normally create automatically when there is no database already set up. entrypoint.sh will later chown the directory.

The problem is that the container relies on this behavior for successful initialization, but it can break when using a volume to mount the data dir from another long-running file system (whether on the host or another container): when a the container is started on an empty volume, the mysql user may have write permissions there (because the volume is writable to anyone or because the volume was previously used to host another mysql database and the admin just rm -rf $vol/* it). If that is the case, then the first call to mysqld --help will create the innodb log files and then initialization will fail.

問題はパーミッションの1つです:コンテナにrootが所有するデータディレクトリ/ var / lib / mysqlがあるので、entrypoint.shがmysqld --helpを呼び出してデータディレクトリを取得すると、そのディレクトリはmysqldとmysqldによって書き込み可能になりません すでに設定されているデータベースがない場合に自動的に作成されるinnodbログファイルを書き込むことはできません。 entrypoint.shは後でディレクトリをchownします。

問題は、コンテナが初期化を成功させるためにこの動作に依存していることですが、ボリュームを使用して別の長時間実行中のファイルシステム(ホストまたは別のコンテナ上)からデータディレクトリをマウントすると、 空のボリューム上では、mysqlユーザは書き込み権限を持つことがあります(ボリュームは誰にでも書き込み可能であるため、以前は別のmysqlデータベースとadminだけをホストするために使用されたためです)。 その場合、mysqld --helpへの最初の呼び出しは、innodbログファイルを作成し、初期化は失敗します。

    {
        "Id": "73e8bcf37ecd0f4c6d18a31700d970bfb5dce7d38cd293c08dac8f9877675475",
        "Created": "2018-02-01T07:24:25.868427524Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "mysqld"
        ],
        "State": {
            "Status": "exited",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 1,
            "Error": "",
            "StartedAt": "2018-02-01T07:24:26.212027863Z",
            "FinishedAt": "2018-02-01T07:24:28.291820513Z"
        },
        "Image": "sha256:ad51d2fd8ddc6755683236f42764c1724df295168d20e590dead21e87addd64a",
        "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/73e8bcf37ecd0f4c6d18a31700d970bfb5dce7d38cd293c08dac8f9877675475/resolv.conf",
        "HostnamePath": "/mnt/sda1/var/lib/docker/containers/73e8bcf37ecd0f4c6d18a31700d970bfb5dce7d38cd293c08dac8f9877675475/hostname",
        "HostsPath": "/mnt/sda1/var/lib/docker/containers/73e8bcf37ecd0f4c6d18a31700d970bfb5dce7d38cd293c08dac8f9877675475/hosts",
        "LogPath": "/mnt/sda1/var/lib/docker/containers/73e8bcf37ecd0f4c6d18a31700d970bfb5dce7d38cd293c08dac8f9877675475/73e8bcf37ecd0f4c6d18a31700d970bfb5dce7d38cd293c08dac8f9877675475-json.log",
        "Name": "/reliefdock_mysql_1",
        "RestartCount": 0,
        "Driver": "aufs",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/projects/data/mysql:/var/lib/mysql:rw",
                "/projects/data/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "reliefdock_backend",
            "PortBindings": {
                "3306/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "3306"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0
        },
        "GraphDriver": {
            "Data": null,
            "Name": "aufs"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/projects/data/mysql",
                "Destination": "/var/lib/mysql",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/projects/data/mysql/docker-entrypoint-initdb.d",
                "Destination": "/docker-entrypoint-initdb.d",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "73e8bcf37ecd",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "3306/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "MYSQL_PASSWORD=secret",
                "MYSQL_ROOT_PASSWORD=root",
                "MYSQL_USER=default",
                "TZ=UTC",
                "MYSQL_DATABASE=default",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GOSU_VERSION=1.7",
                "MYSQL_MAJOR=5.7",
                "MYSQL_VERSION=5.7.21-1debian8"
            ],
            "Cmd": [
                "mysqld"
            ],
            "ArgsEscaped": true,
            "Image": "reliefdock_mysql",
            "Volumes": {
                "/docker-entrypoint-initdb.d": {},
                "/var/lib/mysql": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "86652e64d142e4e41bef740a5688b892edd0ae4d8b2a858b8c257ab27d4a9c11",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "reliefdock",
                "com.docker.compose.service": "mysql",
                "com.docker.compose.version": "1.11.1"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "8020f396e8afbd4561cea12ed031ede67248f581a291ac80f74a791a52c5d2bf",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/8020f396e8af",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "reliefdock_backend": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "73e8bcf37ecd",
                        "mysql"
                    ],
                    "NetworkID": "414c537ce6ec7deda3c73f3f3e3e2bf825e6eb423eed8c68a4c155a2623156bd",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
        }
    }
]

docker build 時に、Dockerfileの1行ごとにイメージをキャッシュする

EntryPoint と Commandの違い

Docker-composeを使わず、単体のdockerを使うと起動できる

windows7 docker でのmysqlの起動について

Python 動かんぞー

apt-get update -yqq && \
apt-get install -y python2.7
$docker-machine ssh default
sudo vi /etc/resolv.conf
cat /etc/resolv.conf
search ngc
nameserver 10.0.2.3
nameserver 8.8.8.8
nameserver 8.8.4.4

/etc/resolv.conf は、read only なのでsudo で実行 * docker-machineコマンド - Qiita

  • エラーメッセージ変わった「Bad IP」から、「Bad header line」になった。
[E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/python-defaults/
python-minimal_2.7.12-1~16.04_amd64.deb  Bad header line Bad header data [IP: 91
.189.88.161 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/python2.7/libpyt
hon2.7-stdlib_2.7.12-1ubuntu0~16.04.3_amd64.deb  0  OK [IP: 91.189.88.162 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-mis
sing?
ERROR: Service 'workspace' failed to build: The command '/bin/sh -c if [ ${INSTA
LL_PYTHON} = true ]; then   apt-get -yqq update   && apt-get -y install python2.
7 python-pip python-dev build-essential   && pip install --upgrade pip   && pip
install --upgrade virtualenv ;fi' returned a non-zero code: 100

参考