AWS Workspaces を考える

イシュー

  • AWS Workspaces を考える

参考

windows7 docker-compose の npm installでエラー

イシュー

  • ようやくwindows7 docker-compose で、mysql が動いて angularの環境を整えようと思ったら、またnpm installでエラー

内容

root@e3f7d6a3b4b2:/var/www/projects/relief-form# npm install angular-cli --save
npm WARN deprecated angular-cli@1.0.0-beta.28.3: angular-cli has been renamed to @angular/cli. Please update your dependencies.
npm WARN deprecated gulp-util@3.0.7: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN enoent ENOENT: no such file or directory, open '/var/www/projects/relief-form/package.json'
npm WARN @angular/core@2.4.10 requires a peer of rxjs@^5.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN relief-form No description
npm WARN relief-form No repository field.
npm WARN relief-form No README data
npm WARN relief-form No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: mkdirp@0.5.1 (node_modules/@angular-cli/ast-tools/node_modules/mkdirp):
npm WARN rofs SKIPPING OPTIONAL DEPENDENCY: EROFS: read-only file system, symlink '../mkdirp/bin/cmd.js' -> '/var/www/projects/relief-form/node_modules/@angular-cli/ast-tools/node_modules/.bin/mkdirp'

npm ERR! path ../typescript/bin/tsc
npm ERR! code EROFS
npm ERR! errno -30
npm ERR! syscall symlink
npm ERR! rofs EROFS: read-only file system, symlink '../typescript/bin/tsc' -> '/var/www/projects/relief-form/node_modules/@angular-cli/ast-tools/node_modules/.bin/tsc'
npm ERR! rofs Often virtualized file systems, or other file systems
npm ERR! rofs that don't support symlinks, give this error.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-02-02T10_22_18_409Z-debug.log
root@e3f7d6a3b4b2:/var/www/projects/relief-form# ls

mount bind

virtualbox x シンボリックリンク

npm install でKilledされた

angular プロジェクトで、npm install したら、not found: python

gyp verb `which` failed Error: not found: python

ng build 時にエラー

TypeError: Cannot destructure property `bold` of 'undefined' or 'null'.
参考

バージョンを確認する

(動いている)開発環境のバージョン
$ ng --version
@angular/cli: 1.4.9
node: 6.9.5

$ python --version          
Python 2.7.12

(エラーになった)Docker環境のバージョン

$ ng --version
Angular CLI: 1.6.7
Node: 9.5.0
OS: linux x64

$ python -V
Python 2.7.12

typescriptなしで入れなおした

$ ng --version
Angular CLI: 1.6.7
Node: 8.9.4
OS: linux x64
Angular: error
... cli, common, compiler, compiler-cli, core, forms, http
... platform-browser, platform-browser-dynamic, router

typescript: error
webpack: error
$

Python でも落ちる

ERROR: Service 'workspace' failed to build: The command '/bin/sh -c if [ ${INSTALL_PYTHON} = true ]; then   apt-get update   && apt-get -y install python python-pip python-dev build-essential    && pip install --upgrade pip    && pip install --upgrade virtualenv ;fi' returned a non-zero code: 100
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/python-defaults/
python-minimal_2.7.11-1_amd64.deb  Bad header line Bad header data [IP: 91.189.8
8.149 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  Bad header line Bad header data
 [IP: 91.189.88.162 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/python-defaults/
libpython-stdlib_2.7.11-1_amd64.deb  Bad header line Bad header data [IP: 91.189
.88.152 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 update   && apt-get -y install python python
-pip python-dev build-essential    && pip install --upgrade pip    && pip instal
l --upgrade virtualenv ;fi' returned a non-zero code: 100
参考

古いイメージを削除する

docker images | awk 'NR>1 {print $3}' | xargs docker rmi

イメージを取得しなおす

bad header エラー

Err:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-minimal amd64 2.7.11-1

参考

/etc/apt/souces.list を編集する

docker-compose で dns が設定できる(情報古い)

apt /sources.list

docker-daemon

/var/lib/boot2docker/profile
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    && pi
p install --upgrade virtualenv ;fi' returned a non-zero code: 100
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  Bad header line Bad header data
 [IP: 91.189.88.152 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-mis
sing?

docker-machine い

sudo vi /etc/resolv.conf

で、nameserver 8.8.8.8 を追加したら、インストールできた。

apt-get -o Acquire::Queue-mode=access -o Acquire::http::Dl-Limit=70 -y install python2.7 python-pip python-dev build-essential

apt.conf.d の種類

ディスクがいっぱいになった

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

参考

laravel test

イシュー

  • laravel でテスト作成

参考

バージョン指定でlaradockをチェックアウト

git clone --depth=1 -b v5.8.5 git@github.com:laradock/laradock.git
docker volume ls

Google カレンダー風JSライブラリ

イシュー

  • Google カレンダー風JSライブラリ

参考

Windows Tips

イシュー

コマンドプロンプトのコードページをUTF-8にする

Angular2 利用例

イシュー

  • Vue とか React はあるのに、Anguar2はないのか

参考