技術をかじる猫

適当に気になった技術や言語、思ったこと考えた事など。

UEFI でデュアルブート設定した Ubuntu を削除する

といってもメモだが…
手順はこんな感じ。

qiita.com

cmd.exe を管理者権限で起動して操作します。
因みに、自分の環境(XPS15)だと list disk に反応はなく、list volume で参照したら存在した。
まぁ、1ディスクで二つ入ってるからなぁ

C:\Windows\system32>diskpart

Microsoft DiskPart バージョン 10.0.16299.15

Copyright (C) Microsoft Corporation.
コンピューター: DESKTOP-OFE415F

DISKPART> list volume

  Volume ###  Ltr Label        Fs    Type        Size     Status     Info
  ----------  --- -----------  ----  ----------  -------  ---------  --------
  Volume 0     C                NTFS   Partition    476 GB  正常         ブート
  Volume 1         回復           NTFS   Partition    499 MB  正常         非表示
  Volume 2                      FAT32  Partition    100 MB  正常         システム

DISKPART> sel volume=2

ボリューム 2 が選択されました。

DISKPART> assign letter=d:

DiskPart はドライブ文字またはマウント ポイントを正常に割り当てました。

あとはリンク先と変わりません。

あとは管理ツールから Linux パーティションを消して Windows 領域に統合すればおしまいです。

XPS15 に Ubuntu16.4 入れたはいいけど…

あれやこれの問題が起きたのでメモ

インストール

基本的にはここに書いてあるとおり。

qiita.com

なのだけど、ここには注記がある。

日本語プロジェクトから Ubuntu image を落として使ってはいけない という点。

何が起きるかというと、2018/04/08 時点では、Ubuntu のバージョンが若干古く、しかも「Wifi にバグを抱えたバージョン」であるようで、無線 LAN が息をせずに文鎮になりかけた。
英語 本家から落としてインストールすることで、これは事なきを得た。

起動したはいいがファンがうるさい

何が起きてたかというと、搭載の nvidia geforce 1050 が暴走でもしてるのかと思うくらい動きまわってた。
軽く探しまわってみたところ、どうにも Windows にだけ最適化してて、Ubuntu では微妙…とのこと。

そんなもんメインでぶん回せはうるさくなるのは当たり前だろう…ということで、眠らせる方法を探した。

$ prime-select query

というコマンドがあわかり、引数で query: 現在メイン稼働の GPU 表示。 intel: IntelGPU をメイン使用設定。nvidia: Geforce をメイン使用設定。ができることがわかった。 これで少しファンの音が小さくなった。

追記:やったら再起動後不安定になったという…普通に Htper-Vで入れた方がいい気がする

Docker(17.12.0) docker-compose 試してみた

と言っても言うほど難しい話ではなく、複数起動してたコンテナをスクリプトでまとめてやるだけの話。

docker-compose.yml を下記の様に記述。

version: '3.1'
services:
  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_PASSWORD: password
  mysql:
    image: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password

そして同一ディレクトリ上で

$ docker-compose up 
Creating network "composeexample_default" with the default driver
Pulling mysql (mysql:5.7)...
5.7: Pulling from library/mysql
Digest: sha256:4f9323cb4aeca062fd1a341b50c7721b9aef6bff3ded806dec0897323b8b7be8
Status: Downloaded newer image for mysql:5.7
  # 中略
wordpress_1  | [Sun Feb 18 01:35:35.318708 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.2 configured -- resuming normal operations
wordpress_1  | [Sun Feb 18 01:35:35.318781 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

これでいちいちパラメータとか覚えなくて済むと言うのはとても楽でよい。

Docker(17.12.0) Dockerfile を使ってアプリケーションイメージを作成する

まずはデプロイするアプリケーションから。
これは Playframework のものを…

ってダメだお前…依存多すぎ DL 遅すぎ…。
今回試したいのは Play じゃないんだってば(汗

Dockerfile をまず作る。

$ vim Dockerfile
FROM ubuntu

# install python3
RUN apt-get update -y
RUN apt-get install python3 -y

# Create application dir
RUN mkdir /app
ADD index.html /app

# Start web server
WORKDIR /app

# Open port
EXPOSE 8000
CMD [ "python3", "-m", "http.server", "8000" ]

Python をさっさとインストールして、/app 配下で web サーバを 8000 ポートで立ち上げろという指示。
どーでもいいが、Ubuntupython は普通に 2.6 なんよね…Python3 インストールするとコマンドが python3 とかホントヤダ…

index.html はこんな感じでいいかね?

<html>
<body>
  <p>Simple message.</p>
</body>
</html>

という事でビルド

$ docker build -t example/python-web .
Sending build context to Docker daemon  3.072kB
Step 1/8 : FROM ubuntu
 ---> 0458a4468cbc
Step 2/8 : RUN apt-get update -y
 ---> Using cache
 ---> e804ebbf1b24
Step 3/8 : RUN apt-get install python3 -y
 ---> Running in 88714e60b80d
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  中略
Step 7/8 : EXPOSE 8000
 ---> Running in da3dff3d02ea
Removing intermediate container da3dff3d02ea
 ---> 5d96e9b282c6
Step 8/8 : CMD [ "python", "-m http.server", "8000" ]
 ---> Running in 02858ca42d76
Removing intermediate container 02858ca42d76
 ---> 538e92c4647b
Successfully built 538e92c4647b
Successfully tagged example/python-web:latest

そして起動

$ docker run -p 8080:8000 --name py-web example/python-web

OK 起動した

f:id:white-azalea:20180217230019p:plain

Docker(17.12.0) Dockerfile からのイメージ作成

内容的には前回やった事を自動化する。

white-azalea.hatenablog.jp

だってこんなのイメージで持ち続けるって大変じゃね?
ってことで、スクリプトでイメージの作り方を指定するらしい。

XXXXXXXX$ cat Dockerfile 
FROM ubuntu

# Install requirements.
RUN apt-get update -y

# install ubuntu node
RUN apt-get install curl nodejs npm -y
RUN npm cache clean

# install n and nodejs stable
RUN npm install n -g
RUN n stable
RUN ln -sf /usr/local/bin/node /usr/bin/node

# remove ubuntu default node
RUN apt-get purge -y nodejs npm

ubuntu をベースに実行するコマンドを列挙しただけの簡易構成。

XXXXXXX$ docker build -t ubuntu-node .
Sending build context to Docker daemon  2.048kB
Step 1/8 : FROM ubuntu
 ---> 0458a4468cbc
Step 2/8 : RUN apt-get update -y
 ---> Running in 87ece63764c1
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [58.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [563 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
  中略
Removing intermediate container c06f58876486
 ---> 388c19df4ec2
Successfully built 388c19df4ec2
Successfully tagged ubuntu-node:latest

というログを吐いてビルド終了。
早速確認してみる。

XXXXXXX:nodeimg azalea$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
ubuntu-node         latest              388c19df4ec2        About a minute ago   562MB
wordpress           latest              ef4787e1820e        8 days ago           410MB
ubuntu              latest              0458a4468cbc        3 weeks ago          112MB
mysql               latest              f008d8ff927d        4 weeks ago          409MB
nginx               latest              3f8a4339aadd        7 weeks ago          108MB
hello-world         latest              f2a91732366c        2 months ago         1.85kB
XXXXXXX:nodeimg azalea$ 

無事 ubuntu-node イメージが出来上がった。

XXXXXXX$ docker run ubuntu-node node --version
v9.4.0

ひゃっはー

Docker(17.12.0) 汚せる nodejs 実行環境を作る

そして、自分の用途を考えると、何より色々試せるサンドボックス環境が欲しかったのだ。
ならば作ろうじゃないか Docker で!

自分がよく作るだろう環境を image 化する

という事で、おもむろに Ubuntu イメージからコンテナを作成する。

XXXXXXX:~ azalea$ docker run --name node-ubuntu -it ubuntu /bin/bash
root@7404156c11f4:/# apt-get update -y
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]                               
Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [58.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]                      
   中略                                                                                                              
Get:21 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [7172 B]                                                                                                                  
Fetched 24.8 MB in 12s (2009 kB/s)                                                                                                                                                                         
Reading package lists... Done

初っ端は更新から。

そしたら、デフォルトパッケージで nodejsnpm をインストールする。
ただしこの時点では node コマンドは使えなくて nodejs コマンドというクソっぷり。

root@7404156c11f4:/# apt-get install nodejs npm -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  binutils build-essential bzip2 ca-certificates cpp cpp-5 dpkg-dev fakeroot file g++ g++-5 gcc gcc-5 gcc-5-base gyp ifupdown iproute2 isc-dhcp-client isc-dhcp-common javascript-common
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libatm1 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libdns-export162 libdpkg-perl libexpat1 libfakeroot
  libffi6 libfile-fcntllock-perl libgcc-5-dev libgdbm3 libgmp10 libgomp1 libicu55 libisc-export160 libisl15 libitm1 libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore liblsan0 libmagic1
  libmnl0 libmpc3 libmpfr4 libmpx0 libperl5.22 libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libquadmath0 libsqlite3-0 libssl-dev libssl-doc libssl1.0.0 libstdc++-5-dev libstdc++6 libtsan0
  libubsan0 libuv1 libuv1-dev libxtables11 linux-libc-dev make manpages manpages-dev mime-support netbase node-abbrev node-ansi node-ansi-color-table node-archy node-async node-block-stream
  node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-gyp node-inherits
  node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once
  node-osenv node-qs node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent node-underscore node-which nodejs-dev
  openssl patch perl perl-modules-5.22 python python-minimal python-pkg-resources python2.7 python2.7-minimal rename xz-utils zlib1g-dev
  中略
Setting up npm (3.5.2-0ubuntu4) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ca-certificates (20170717~16.04.1) ...
Updating certificates in /etc/ssl/certs...
148 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.

ここで、npm を使って n コマンドをインストールする。

root@7404156c11f4:/# npm cache clean
root@7404156c11f4:/# npm install n -g
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
/usr/local/lib
`-- n@2.1.8 

あとは wget なり curl なりをインストールして、n stable で最新安定板の node を入れてしまう。

root@7404156c11f4:/# apt-get install wget -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
  中略
Processing triggers for libc-bin (2.23-0ubuntu10) ...
root@7404156c11f4:/# n stable

     install : node-v9.4.0
       mkdir : /usr/local/n/versions/node/9.4.0
       fetch : https://nodejs.org/dist/v9.4.0/node-v9.4.0-linux-x64.tar.gz
   installed : v9.4.0

root@7404156c11f4:/# ln -sf /usr/local/bin/node /usr/bin/node
root@7404156c11f4:/# node -v
v9.4.0

Ubuntu デフォルトの nodejs とかいらないので削除

root@7404156c11f4:/# apt-get purge -y nodejs npm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  binutils build-essential bzip2 cpp cpp-5 dpkg-dev fakeroot file g++ g++-5 gcc gcc-5 gyp ifupdown iproute2 isc-dhcp-client isc-dhcp-common javascript-common libalgorithm-diff-perl
  中略
Removing nodejs (4.2.6~dfsg-1ubuntu4.1) ...

しっかしデフォルトだと nodejs バージョンが古いものである。
まずはこれで、nodejs 用のコンテナができたわけだ。

後はイメージ化しておくと、コンテナ作成が楽でいい

XXXXXXX:~ azalea$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
7404156c11f4        ubuntu              "/bin/bash"              7 hours ago         Exited (0) 20 seconds ago                       node-ubuntu
d44b8f1d3bc2        wordpress           "docker-entrypoint.s…"   20 hours ago        Exited (137) 20 hours ago                       web
d551c8998080        mysql               "docker-entrypoint.s…"   20 hours ago        Exited (137) 20 hours ago                       db
ac386b7fd1df        hello-world         "/hello"                 3 days ago          Exited (0) 3 days ago                           clever_aryabhata
XXXXXXX:~ azalea$ docker commit --help

Usage:  docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Create a new image from a container's changes

Options:
  -a, --author string    Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
  -c, --change list      Apply Dockerfile instruction to the created image
  -m, --message string   Commit message
  -p, --pause            Pause container during commit (default true)
XXXXXXX:~ azalea$ docker commit 7404156c11f4 nodejs9-sandbox
sha256:a93c21a71dade1f0579fa9e9d2ef29cf9f02a79599c740d77bd0e143914954cc
XXXXXXX:~ azalea$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nodejs9-sandbox     latest              a93c21a71dad        5 seconds ago       529MB
wordpress           latest              ef4787e1820e        8 days ago          410MB
ubuntu              latest              0458a4468cbc        3 weeks ago         112MB
mysql               latest              f008d8ff927d        4 weeks ago         409MB
nginx               latest              3f8a4339aadd        7 weeks ago         108MB
hello-world         latest              f2a91732366c        2 months ago        1.85kB
XXXXXXX:~ azalea$ 

後は使いたいときに使えるはずだ。
まずはその検証のために元を削除してみる。

XXXXXXX:~ azalea$ docker container ls -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
7404156c11f4        ubuntu              "/bin/bash"              7 hours ago         Exited (0) 8 minutes ago                        node-ubuntu
d44b8f1d3bc2        wordpress           "docker-entrypoint.s…"   20 hours ago        Exited (137) 20 hours ago                       web
d551c8998080        mysql               "docker-entrypoint.s…"   21 hours ago        Exited (137) 20 hours ago                       db
ac386b7fd1df        hello-world         "/hello"                 3 days ago          Exited (0) 3 days ago                           clever_aryabhata
XXXXXXX:~ azalea$ docker rm node-ubuntu
node-ubuntu
XXXXXXX:~ azalea$ docker container ls -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
d44b8f1d3bc2        wordpress           "docker-entrypoint.s…"   20 hours ago        Exited (137) 20 hours ago                       web
d551c8998080        mysql               "docker-entrypoint.s…"   21 hours ago        Exited (137) 20 hours ago                       db
ac386b7fd1df        hello-world         "/hello"                 3 days ago          Exited (0) 3 days ago                           clever_aryabhata
XXXXXXX:~ azalea$ 

そしたらイメージから起動する。

XXXXXXXX:~ azalea$ docker run -it nodejs9-sandbox
root@6cfb7120e148:/# 

ひゃっはー。
そして関連コンテナを全て docker rm で削除した後

XXXXXXX:~ azalea$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nodejs9-sandbox     latest              a93c21a71dad        About an hour ago   529MB
wordpress           latest              ef4787e1820e        8 days ago          410MB
ubuntu              latest              0458a4468cbc        3 weeks ago         112MB
mysql               latest              f008d8ff927d        4 weeks ago         409MB
nginx               latest              3f8a4339aadd        7 weeks ago         108MB
hello-world         latest              f2a91732366c        2 months ago        1.85kB
XXXXXXX:~ azalea$ docker image rm a93c21a71dad 
Untagged: nodejs9-sandbox:latest
Deleted: sha256:a93c21a71dade1f0579fa9e9d2ef29cf9f02a79599c740d77bd0e143914954cc
Deleted: sha256:ccfc46bb38a596f9d7965ce6aa2f15b905a44227b10c7e6405cde577b24ac586
XXXXXXX:~ azalea$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
wordpress           latest              ef4787e1820e        8 days ago          410MB
ubuntu              latest              0458a4468cbc        3 weeks ago         112MB
mysql               latest              f008d8ff927d        4 weeks ago         409MB
nginx               latest              3f8a4339aadd        7 weeks ago         108MB
hello-world         latest              f2a91732366c        2 months ago        1.85kB

docker image rm イメージ名 でイメージ削除までいける事がわかった。

Docker(17.12.0)で少し遊んで見る

これの続き

white-azalea.hatenablog.jp

Wordpress なんて 11 年前の学生時代に弄ってた OSS を簡単に動かす紹介があったのでやって見た。

XXXXXXX:~ azalea$ docker run -d -e MYSQL_ROOT_PASSWORD=password --name db mysql
Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql
f49cf87b52c1: Pull complete 
78032de49d65: Pull complete 
837546b20bc4: Pull complete 
9b8316af6cc6: Pull complete 
1056cf29b9f1: Pull complete 
86f3913b029a: Pull complete 
f98eea8321ca: Pull complete 
3a8e3ebdeaf5: Pull complete 
4be06ac1c51e: Pull complete 
920c7ffb7747: Pull complete 
Digest: sha256:7cdb08f30a54d109ddded59525937592cb6852ff635a546626a8960d9ec34c30
Status: Downloaded newer image for mysql:latest
58c04fb86b7ec40664344c91610f1caf0fa20d31238ad69248e61bee0dea4456
XXXXXXX:~ azalea$ 
XXXXXXX:~ azalea$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
58c04fb86b7e        mysql               "docker-entrypoint.s…"   16 seconds ago      Up 20 seconds       3306/tcp            db
XXXXXXX:~ azalea$ 

MySQL を root パスワード password で起動。
ポート番号は MySQL デフォルトポートなんね。

続いて wordpress

XXXXXXXX:~ azalea$ docker run --link db:mysql -p 8080:80 -e WORDPRESS_DB_PASSWORD=password --name web wordpress
Unable to find image 'wordpress:latest' locally
latest: Pulling from library/wordpress
e7bb522d92ff: Already exists 
75651f247827: Pull complete 
dbcf8fd0150f: Pull complete 
de80263f26f0: Pull complete 
65be8ad4c5fd: Pull complete 
239d5fed0dda: Pull complete 
5ab39b683a9f: Pull complete 
4a3f54f2d93a: Pull complete 
28c970ad99e9: Pull complete 
86b02bcfc0c2: Pull complete 
a21cb128d1e1: Pull complete 
620a1b563498: Pull complete 
2b7708d1b98c: Pull complete 
0086574a434b: Pull complete 
9eb9edc5beda: Pull complete 
660c359d962d: Pull complete 
7668cac2f2dd: Pull complete 
57950765f0c3: Pull complete 
25f60226e8a5: Pull complete 
Digest: sha256:9a6067b6f4d950e4a5fea699d4e9537bdcc2375f651e1ce5c98aa4dc2c61d1b7
Status: Downloaded newer image for wordpress:latest
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
[Fri Feb 16 13:14:08.132796 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.2 configured -- resuming normal operations
[Fri Feb 16 13:14:08.132915 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

うん、起動したので http://localhost:8080 アクセス

f:id:white-azalea:20180216222051p:plain

2コマンドか…楽になったものだ。
そこでもう一声。

qiita.com

こっちの記述も試してみようと思う。
つまり Network 機能だ。

まずネットワークが現在どうなってるか確認する

XXXXXXX:~ azalea$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
90f602f39b31        bridge              bridge              local
d405e0672e62        host                host                local
69b041527ecb        none                null                local

ほむほむ。
Wordpress 用のネットワーク作っちゃうぞー

XXXXXXX:~ azalea$ docker network create wordpress
d632af3c1df0adaf37df9f99ac0bac2cc1e4b06dcbf3ac5a473e2655ae2f9383
XXXXXXX:~ azalea$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
90f602f39b31        bridge              bridge              local
d405e0672e62        host                host                local
69b041527ecb        none                null                local
d632af3c1df0        wordpress           bridge              local

ならここに所属するように指定して起動すればいいのか

XXXXXXX:~ azalea$ docker run -d -e MYSQL_ROOT_PASSWORD=password --net wordpress --name db mysql
ba9ece2b29ea57013671334b5e2de19ed1046154892d0c0790c86ded093c5586
XXXXXXX:~ azalea$ docker run --link db:mysql -p 8080:80 -e WORDPRESS_DB_PASSWORD=password --net wordpress --name web wordpress
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.3. Set the 'ServerName' directive globally to suppress this message
[Fri Feb 16 13:32:37.914171 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.2 configured -- resuming normal operations
[Fri Feb 16 13:32:37.914294 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

ここまでに見たエラー
まずは、docker kill したやつを同じコマンドで起動しようとして怒られたパターン。

kill はプロセスを kill するだけで、コンテナに一切の手をつけないって事なのか。
docker start web で問題なく起動した。

XXXXXXX:~ azalea$ docker run --link db:mysql -p 8080:80 -e WORDPRESS_DB_PASSWORD=password --net wordpress --name web wordpress
docker: Error response from daemon: Conflict. The container name "/web" is already in use by container "07627d915bde1df0fa5bbdc11044cf576ce28ed5595ef9e6e2a92d40052ecb54". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
XXXXXXX:~ azalea$ docker rm web
web

しかし ubuntu は毎回 run でイケるのだが…この差はなんだ?
疑問に思って Kitematic 眺めて見たら、ubuntu は run するたびに別コンテナが作られてたという…なるほどな(汗

試しに、docker run --name test_ubuntu -it ubuntu /bin/bash して Ctrl + D で終了。
そして start からのインタラクティブ指定したら…

XXXXXXX:~ azalea$ docker start test_ubuntu -i
root@f42f937734aa:/# 

普通にログインできた。
しかも前回起動時のファイルが残ってたよ…なるほどね。

もうひとつは Network 構築後に --link が省略できないかなと試してみて、エラー吐かれたパターン。

XXXXXXX:~ azalea$ docker run --link mysql -p 8080:80 -e WORDPRESS_DB_PASSWORD=password --net wordpress --name web wordpress
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html

Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known in Standard input code on line 22

Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in Standard input code on line 22

ここから見るに、Network はイメージ的には同一のイントラにホスト(コンテナ)を放り込むだけなのに対して、--link はコンテナ同士を殆どシームレスに繋いでしまう事らしい。

扱い違うのね…

やっと概要掴んで来た。

  • image
    コンテナ作成の為の元情報。
    run 実行するとここを元にコンテナを作る。
  • container
    実際に動作する単位。
    start, stop で起動・停止を行う。