企業の壁とエンジニアの知識の共有と老人の消え方

厳密に言わなくても、企業内のシステムに関しては、投資と効果で成り立つ倫理がある。

競合だの、守秘義務だの、大切な、だけども、多分、原始時代までいかなくとも、
人と人でないものの戦いには不利であろうと思われる色々な生存規則。

たまたま、Hadoop をきっかけにして、Open Source に近いところに、
再度、出かけていって、何の役にも立たない年寄りでも、
水先案内になれればと、へろへろな案内をしてきたのだけれども。

あと、わずかになってきて、ふと思う。
随分と、勿体ない事をしているんじゃないかって。


いわゆる、Web系というか、ゲームやら広告やらの、あぶく銭系のドメインと違い、
僕のいる世界は、
競争のために隠蔽するのが良いという世界。

汚染を防ぐ事と、化学反応を起こす事は、別物だと思うのだけれど、
混ぜるな危険な世界観でできあがっている。。


置き土産に、何かしら、種をまこうかなぁ。
アップルシードほどでは、ないにしろ、化学反応は、必要だ。
老人が、媒体になるのは、もうそろそろ、限界だろう。。

Kibana 4 beta2 を Docker で動かしてみる -- boot2docker

Docker Image の作成。

DockerFile とかを、適当に作って置いたので、これを使っている。
https://github.com/guutara/dockfile-kibana4

まずは、boot2dockerを起動する。

MBA20120331:dockerfile-elasticsearch4 guutara$ boot2docker start
Waiting for VM and Docker daemon to start...
.....................ooooooooooooooooooooooooo
Started.
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/key.pem

To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://192.168.59.103:2376
    export DOCKER_CERT_PATH=/Users/guutara/.boot2docker/certs/boot2docker-vm
    export DOCKER_TLS_VERIFY=1

MBA20120331:dockerfile-elasticsearch4 guutara$ export DOCKER_HOST=tcp://192.168.59.103:2376
MBA20120331:dockerfile-elasticsearch4 guutara$     export DOCKER_CERT_PATH=/Users/guutara/.boot2docker/certs/boot2docker-vm
MBA20120331:dockerfile-elasticsearch4 guutara$     export DOCKER_TLS_VERIFY=1
MBA20120331:dockerfile-elasticsearch4 guutara$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Dockerfile のあるディレクトリで行う。

MBA20120331:dockerfile-kibana4 guutara$ docker build -t guutara/kibana4-b2 .
Sending build context to Docker daemon 58.88 kB
Sending build context to Docker daemon 
Step 0 : FROM dockerfile/java:oracle-java7
 ---> a643f54fef40
Step 1 : RUN cd /tmp &&   wget https://download.elasticsearch.org/kibana/kibana/kibana-4.0.0-BETA2.tar.gz &&   tar xvzf kibana-4.0.0-BETA2.tar.gz &&   rm -f kibana-4.0.0-BETA2tar.gz &&   mv /tmp/kibana-4.0.0-BETA2 /kibana
 ---> Running in a3afe2be6e1d.
.
.
Step 3 : ENTRYPOINT /kibana/bin/kibana
 ---> Running in 89b1f0b0f6ea
 ---> ea2d1c42aceb
Removing intermediate container 89b1f0b0f6ea
Step 4 : EXPOSE 5601
 ---> Running in f163b3dd6a71
 ---> 1f22d4daead2
Removing intermediate container f163b3dd6a71
Successfully built 1f22d4daead2

MBA20120331:dockerfile-kibana4 guutara$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
guutara/kibana4-b2      latest              1f22d4daead2        21 minutes ago      768.1 MB
guutara/elasticsearch   1.4.0               cffbdbd80f9c        12 days ago         755.9 MB
guutara/elasticsearch   1.3.2               e1b42108cc83        5 weeks ago         755.5 MB
dockerfile/java         oracle-java7        a643f54fef40        5 weeks ago         722 MB
chung/centos7-up        latest              3a22ebba07c7        9 weeks ago         288.3 MB
centos                  centos7             70214e5d0a90        11 weeks ago        224 MB

これで、Imageは、作成完了。

Container の作成から起動確認

先に、elasticsearch を起動しておく。

MBA20120331:dockerfile-elasticsearch4 guutara$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
MBA20120331:dockerfile-elasticsearch4 guutara$ docker run -d -p 9200:9200 -p 9300:9300 -name el1.4-up guutara/elasticsearch:1.4.0
Warning: '-name' is deprecated, it will be replaced by '--name' soon. See usage.
3338665c2dfb431de5f51889436958e0954e5ed3f37277e5d1f19dadaa95a561
MBA20120331:dockerfile-elasticsearch4 guutara$ docker ps
CONTAINER ID        IMAGE                         COMMAND                CREATED             STATUS              PORTS                                            NAMES
3338665c2dfb        guutara/elasticsearch:1.4.0   "/elasticsearch/bin/   8 seconds ago       Up 7 seconds        0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   el1.4-up            

次に、kibana4 を起動する。

MBA20120331:dockerfile-kibana4 guutara$ docker run -d -p 5601:5601 --name kibana4 guutara/kibana4-b2 -e http://192.168.59.103:9200
0311e15a934e95b4e66dd40fec82d7bfc6a7a639b377f2ac9b188f203f522c57
MBA20120331:dockerfile-kibana4 guutara$ docker ps
CONTAINER ID        IMAGE                         COMMAND                CREATED             STATUS              PORTS                                            NAMES
0311e15a934e        guutara/kibana4-b2:latest     "/kibana/bin/kibana    13 seconds ago      Up 11 seconds       0.0.0.0:5601->5601/tcp                           kibana4             
90f62a351e15        guutara/elasticsearch:1.4.0   "/elasticsearch/bin/   26 minutes ago      Up 26 minutes       0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   el1.4-up            

"-e" で、elasticsearch の動作している、URIを指定する。この場合、先ほど起動したURIとポートを指定した。

ブラウザで、確認すると、以下のように表示されたので、動作完了。

まとめ

kibana4を、作ったので、公開してみた。こっちは、色々、使えそうだ。

Elasticsearch 1.4.0 を Docker で動かしてみる -- boot2docker

準備の準備

まずは、boot2dockerをバージョンアップする。

OSX Installer

インストーラを新しくする。

https://github.com/boot2docker/osx-installer/releases/latest

DawnLoad後、Installする。

その後、以下のコマンドを実行する。
この辺りは、Dockerのサイトにのっているとうり。。

MBA20120331:dockerfile-elasticsearch4 guutara$ boot2docker stop
MBA20120331:dockerfile-elasticsearch4 guutara$ boot2docker download
Latest release for boot2docker/boot2docker is v1.3.1
Downloading boot2docker ISO image...
Success: downloaded https://github.com/boot2docker/boot2docker/releases/download/v1.3.1/boot2docker.iso
	to /Users/guutara/.boot2docker/boot2docker.iso
MBA20120331:dockerfile-elasticsearch4 guutara$ boot2docker start
Waiting for VM and Docker daemon to start...
.....................ooooooooooooooooooooooooo
Started.
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/key.pem

To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://192.168.59.103:2376
    export DOCKER_CERT_PATH=/Users/guutara/.boot2docker/certs/boot2docker-vm
    export DOCKER_TLS_VERIFY=1

使う前に、上記、3つの変数は、設定しておこう。。

Docker Image の作成。

DockerFile とかを、適当に作って置いたので、これを使っている。
dockerfile-elasticsearch4

まずは、boot2dockerを起動する。

MBA20120331:dockerfile-elasticsearch4 guutara$ boot2docker start
Waiting for VM and Docker daemon to start...
.....................ooooooooooooooooooooooooo
Started.
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/guutara/.boot2docker/certs/boot2docker-vm/key.pem

To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://192.168.59.103:2376
    export DOCKER_CERT_PATH=/Users/guutara/.boot2docker/certs/boot2docker-vm
    export DOCKER_TLS_VERIFY=1

MBA20120331:dockerfile-elasticsearch4 guutara$ export DOCKER_HOST=tcp://192.168.59.103:2376
MBA20120331:dockerfile-elasticsearch4 guutara$     export DOCKER_CERT_PATH=/Users/guutara/.boot2docker/certs/boot2docker-vm
MBA20120331:dockerfile-elasticsearch4 guutara$     export DOCKER_TLS_VERIFY=1
MBA20120331:dockerfile-elasticsearch4 guutara$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Dockerfile のあるディレクトリで行う。

MBA20120331:dockerfile-elasticsearch4 guutara$ pwd
/Users/guutara/git/dockerfile-elasticsearch4
MBA20120331:dockerfile-elasticsearch4 guutara$ ls
Dockerfile  README.md  config  data
MBA20120331:dockerfile-elasticsearch4 guutara$ docker build -t guutara/elasticsearch:1.4.0 .
Sending build context to Docker daemon 29.46 MB
Sending build context to Docker daemon 
Step 0 : FROM dockerfile/java:oracle-java7
 ---> a643f54fef40
.
.
.
Successfully built cffbdbd80f9c
MBA20120331:dockerfile-elasticsearch4 guutara$ 

MBA20120331:dockerfile-elasticsearch4 guutara$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED              VIRTUAL SIZE
guutara/elasticsearch   1.4.0               cffbdbd80f9c        About a minute ago   755.9 MB
guutara/kibana          4.0.0-BETA1         e3c7448aefd5        3 weeks ago          766.4 MB
guutara/elasticsearch   1.3.2               e1b42108cc83        3 weeks ago          755.5 MB
dockerfile/java         oracle-java7        a643f54fef40        4 weeks ago          722 MB
chung/centos7-up        latest              3a22ebba07c7        7 weeks ago          288.3 MB
centos                  centos7             70214e5d0a90        9 weeks ago          224 MB

これで、Imageは、作成完了。

Container の作成から起動確認

Docker -name で、名前をつけて作成して起動する。

MBA20120331:dockerfile-elasticsearch4 guutara$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
MBA20120331:dockerfile-elasticsearch4 guutara$ docker run -d -p 9200:9200 -p 9300:9300 -name el1.4-up guutara/elasticsearch:1.4.0
Warning: '-name' is deprecated, it will be replaced by '--name' soon. See usage.
3338665c2dfb431de5f51889436958e0954e5ed3f37277e5d1f19dadaa95a561
MBA20120331:dockerfile-elasticsearch4 guutara$ docker ps
CONTAINER ID        IMAGE                         COMMAND                CREATED             STATUS              PORTS                                            NAMES
3338665c2dfb        guutara/elasticsearch:1.4.0   "/elasticsearch/bin/   8 seconds ago       Up 7 seconds        0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   el1.4-up            

DOCKER_HOSTのIPを、何度も叩くのは、面倒なので DOCKER_HOST_IP に設定しておく。

MBA20120331:data guutara$ export DOCKER_HOST_IP=192.168.59.103
MBA20120331:data guutara$ echo $DOCKER_HOST_IP
192.168.59.103


まずは、起動を確認。

MBA20120331:dockerfile-elasticsearch4 guutara$ curl http://$DOCKER_HOST_IP:9200/
{
  "status" : 200,
  "name" : "Kristoff Vernard",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.4.0",
    "build_hash" : "bc94bd81298f81c656893ab1ddddd30a99356066",
    "build_timestamp" : "2014-xx-xxxxxxxx",
    "build_snapshot" : false,
    "lucene_version" : "4.10.2"
  },
  "tagline" : "You Know, for Search"
}

Index作成と、データを検索してみる。使ったのは、kibanaで提供されているデータ。
curl -O http://www.elasticsearch.org/guide/en/kibana/current/snippets/shakespeare.jsonで、データを取得しておく。
先ほどの、gitのdata配下には、データと以下の、しょぼい、shがあるので、それを使っている。

MBA20120331:data guutara$ cat curl-shakespeare 
#/bin/sh
#

echo "Start Index Create" 
curl -XPUT http://$DOCKER_HOST_IP:9200/shakespeare -d '
{
 "mappings" : {
  "_default_" : {
   "properties" : {
    "speaker" : {"type": "string", "index" : "not_analyzed" },
    "play_name" : {"type": "string", "index" : "not_analyzed" },
    "line_id" : { "type" : "integer" },
    "speech_number" : { "type" : "integer" }
   }
  }
 }
}
';

echo

echo "Start Bulk Load"

curl -XPUT  http://$DOCKER_HOST_IP:9200/_bulk --data-binary @shakespeare.json

echo
echo "End "

MBA20120331:data guutara$ sh curl-shakespeare > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   305  100    21  100   284     18    255  0:00:01  0:00:01 --:--:--   255
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 33.6M  100 9791k  100 24.0M   408k  1027k  0:00:23  0:00:23 --:--:--     0

確認してみる。

Indexの確認。

MBA20120331:data guutara$ curl -XGET http://$DOCKER_HOST_IP:9200/_aliases?pretty
{
  "shakespeare" : { }
}


データの確認。

MBA20120331:data guutara$ curl -XGET http://$DOCKER_HOST_IP:9200/shakespeare/_search?
{"took":78,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":111396,"max_score":1.0,"hits":[{"_index":"shakespeare","_type":"line","_id":"46925","_score":1.0,"_source":{"line_id":46926,"play_name":"Julius Caesar","speech_number":13,"line_number":"","speaker":"BRUTUS","text_entry":"Exit LUCIUS"}},{"_index":"shakespeare","_type":"line","_id":"46932","_score":1.0,"_source":{"line_id":46933,"play_name":"Julius Caesar","speech_number":13,"line_number":"2.1.67","speaker":"BRUTUS","text_entry":"Are then in council; and the state of man,"}},{"_index":"shakespeare","_type":"line","_id":"46937","_score":1.0,"_source":{"line_id":46938,"play_name":"Julius Caesar","speech_number":14,"line_number":"2.1.71","speaker":"LUCIUS","text_entry":"Who doth desire to see you."}},{"_index":"shakespeare","_type":"line","_id":"46944","_score":1.0,"_source":{"line_id":46945,"play_name":"Julius Caesar","speech_number":18,"line_number":"2.1.78","speaker":"LUCIUS","text_entry":"By any mark of favour."}},{"_index":"shakespeare","_type":"line","_id":"46949","_score":1.0,"_source":{"line_id":46950,"play_name":"Julius Caesar","speech_number":19,"line_number":"2.1.82","speaker":"BRUTUS","text_entry":"When evils are most free? O, then by day"}},{"_index":"shakespeare","_type":"line","_id":"46951","_score":1.0,"_source":{"line_id":46952,"play_name":"Julius Caesar","speech_number":19,"line_number":"2.1.84","speaker":"BRUTUS","text_entry":"To mask thy monstrous visage? Seek none, conspiracy;"}},{"_index":"shakespeare","_type":"line","_id":"46956","_score":1.0,"_source":{"line_id":46957,"play_name":"Julius Caesar","speech_number":19,"line_number":"","speaker":"BRUTUS","text_entry":"Enter the conspirators, CASSIUS, CASCA, DECIUS BRUTUS, CINNA, METELLUS CIMBER, and TREBONIUS"}},{"_index":"shakespeare","_type":"line","_id":"46963","_score":1.0,"_source":{"line_id":46964,"play_name":"Julius Caesar","speech_number":22,"line_number":"2.1.95","speaker":"CASSIUS","text_entry":"You had but that opinion of yourself"}},{"_index":"shakespeare","_type":"line","_id":"46968","_score":1.0,"_source":{"line_id":46969,"play_name":"Julius Caesar","speech_number":25,"line_number":"2.1.100","speaker":"BRUTUS","text_entry":"He is welcome too."}},{"_index":"shakespeare","_type":"line","_id":"46970","_score":1.0,"_source":{"line_id":46971,"play_name":"Julius Caesar","speech_number":27,"line_number":"2.1.102","speaker":"BRUTUS","text_entry":"They are all welcome."}}]}}

まとめ

dockerfile/elasticsearch · GitHubを参考に、見よう見まねで、作ってみたけど、なんとか動いた。
boot2docker で、動かしてるけど、普通にDockerいれて物理で動かすならもっと違うやり方が出来ると思う。

ちなみに、データの永続化はしてないので、コンテナ消すと全てはなくなるのだよ。(笑)

あと、kibana4も、作ったのだけど、それは、また、気が向いた時にまとめるつもり。

Docker -- Boot2docker

とりあえず、Mac OSX 10.9 に、入れてみる。

Install

ここInstalling Docker on Mac OS Xの指示に従う。

VirtualBoxがインストールされる。
すでに入れてあったので、インストールはしなかったみたいだ。。



boot2docker 実行

クリックすると、こんな感じで、Terminalが開く。

bash
Last login: Sun Sep 14 17:59:05 on ttys000
MBA20120331:~ guutara$ bash
[MBA20120331:~ guutara]$ unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
mkdir -p ~/.boot2docker
[MBA20120331:~ guutara]$ mkdir -p ~/.boot2docker
if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
boot2docker/ ; fiutara]$ if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/. 
/usr/local/bin/boot2docker init 
/usr/local/bin/boot2docker up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2>/dev/null):2375
docker version
[MBA20120331:~ guutara]$ /usr/local/bin/boot2docker init 
Generating public/private rsa key pair.
Your identification has been saved in /Users/guutara/.ssh/id_boot2docker.
Your public key has been saved in /Users/guutara/.ssh/id_boot2docker.pub.
The key fingerprint is:
da:15:10:5d:ae:16:87:59:0c:8d:11:81:12:6e:39:81 guutara@MBA20120331.local
The key's randomart image is:

l):237520331:~ guutara]$ /usr/local/bin/boot2docker up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2>/dev/nul 
Waiting for VM and Docker daemon to start...
.............................................
Started.

To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://192.168.59.103:2375

[MBA20120331:~ guutara]$ docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.1
Git commit (client): fa7b24f
OS/Arch (client): darwin/amd64
Server version: 1.2.0
Server API version: 1.14
Go version (server): go1.3.1
Git commit (server): fa7b24f 

この時点で、VirtulBoxに、VMが起動している。


docker pull

使用するコンテナのイメージを取って来る。とりあえず、centOSの7にした。

[MBA20120331:~ guutara]$ docker pull centos:centos7
Pulling repository centos
70214e5d0a90: Download complete 
511136ea3c5a: Download complete 
34e94e67e63a: Download complete 

docker images

持っているコンテナのイメージを確認する。

[MBA20120331:~ guutara]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos              centos7             70214e5d0a90        2 weeks ago         224 MB

docker run -t -i

コンテナを起動する。
起動する際に、-t で、tty を確保して、-i で、標準出力を開き、/bin/bash で端末アクセスする。
exit で、抜けると停止する。

[MBA20120331:~ guutara]$ docker run -t -i --name centos7-up centos:centos7 /bin/bash
bash-4.2# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  2.7  0.1  11744  2864 ?        Ss   10:46   0:00 /bin/bash
root         9  0.0  0.1  19752  2164 ?        R+   10:46   0:00 ps aux
bash-4.2# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core) 
bash-4.2# uname -a
Linux b35fd83296dd 3.16.1-tinycore64 #1 SMP Fri Aug 22 06:40:10 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
bash-4.2# exit
exit

docker start -i

停止したコンテナを起動する。
起動する際に、-t で、tty を確保して端末アクセスする。
exit で抜けると、停止する。

[MBA20120331:~ guutara]$ docker start -i centos7-up
centos7-up
bash-4.2# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core) 
bash-4.2# uname -a
Linux b35fd83296dd 3.16.1-tinycore64 #1 SMP Fri Aug 22 06:40:10 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
bash-4.2# exit
exit

yum update

最新の状態にコンテナをアップデートしてみる。

[MBA20120331:~ guutara]$ docker start -i centos7-up
centos7-up
bash-4.2# yum update
Loaded plugins: fastestmirror
base                                                                                                      | 3.6 kB  00:00:00     
extras                                                                                                    | 3.4 kB  00:00:00     
updates                                                                                                   | 3.4 kB  00:00:00     
(1/4): extras/7/x86_64/primary_db                                                                         |  26 kB  00:00:00     
(2/4): base/7/x86_64/group_gz                                                                             | 157 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                        | 2.9 MB  00:00:02     
(4/4): base/7/x86_64/primary_db                                                                           | 4.9 MB  00:00:03     
Determining fastest mirrors
.
.
.

Complete!
bash-4.2# exit

docker commit

update したコンテナのイメージを作成する。
images で、確認しておく。

[MBA20120331:~ guutara]$ docker commit centos7-up chung/centos7-up
3a22ebba07c7741599a28eb21997f1cf6dbfdeb2202d230576051fc34d6eb4a6
[MBA20120331:~ guutara]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
chung/centos7-up    latest              3a22ebba07c7        34 seconds ago      288.3 MB
centos              centos7             70214e5d0a90        2 weeks ago         224 MB

docker rm

コンテナを削除する。
これで、yum update したコンテナは削除される。

MBA20120331:~ guutara$  docker rm centos7-up
centos7-up

docker ps -a

コンテナの状態を確認する。

  • a で、動いていないコンテナも表示する。
MBA20120331:~ guutara$  docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

MBA20120331:~ guutara$  docker run -d -i -t --name centos7-chung chung/centos7-up /bin/bash
df0684c80b17d8a90546cf7829e67f326fd172b5ea949bea00b966003c366878
MBA20120331:~ guutara$  docker run -d -i -t --name centos7-org centos:centos7 /bin/bash
ea817f2e6e08c3686680d6660eedd1d973962a0a01f24a2bbd248729d0e0f330
MBA20120331:~ guutara$  docker ps -a
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
ea817f2e6e08        centos:centos7            "/bin/bash"         7 seconds ago       Up 4 seconds                            centos7-org         
df0684c80b17        chung/centos7-up:latest   "/bin/bash"         35 seconds ago      Up 33 seconds                           ce

docker run -d , docker attach

デーモンで動かす時には、-d を付ける。
動かしたまま、抜けるには、CTR-p,CTR-q で、抜ける。

docker start -i でも、再接続可能だけど、attachで、繋げられる。

MBA20120331:~ guutara$  docker ps -a
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
ea817f2e6e08        centos:centos7            "/bin/bash"         5 minutes ago       Up 5 minutes                            centos7-org         
df0684c80b17        chung/centos7-up:latest   "/bin/bash"         6 minutes ago       Up 5 minutes                            centos7-chung       
MBA20120331:~ guutara$  docker attach centos7-org

bash-4.2# ps
  PID TTY          TIME CMD
    1 ?        00:00:00 bash
    8 ?        00:00:00 ps
CTR-p,CTR-q

[MBA20120331:~ guutara]$

MBA20120331:~ guutara$  docker ps -a
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
ea817f2e6e08        centos:centos7            "/bin/bash"         10 minutes ago      Up 10 minutes                           centos7-org         
df0684c80b17        chung/centos7-up:latest   "/bin/bash"         10 minutes ago      Up 10 minutes                           centos7-chung       

boot2docker stop

VMを止めておく。

MBA20120331:~ guutara$ boot2docker stop

マカフィーいれると/usr/local のパーミッションが変更される

MBA20120331:~ guutara$ brew doctor
Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.


マカフィーをいれると、こうなってしまうので、直す。

MBA20120331:~ guutara$ ls -l /usr
total 4
drwxr-xr-x    8 root wheel   272  9 22  2013 X11
lrwxr-xr-x    1 root wheel     3  9 22  2013 X11R6 -> X11
drwxr-xr-x 1069 root wheel 36346  4 23 15:06 bin
drwxr-xr-x  288 root wheel  9792 11 28 17:29 include
drwxr-xr-x  344 root wheel 11696  4 23 15:06 lib
drwxr-xr-x  143 root wheel  4862  4 23 15:07 libexec
drwxr-xr-x    7 root wheel   238  1 28  2012 llvm-gcc-4.2
drwxr-xr-x   18 root wheel   612  3 29 12:13 local
drwxr-xr-x  259 root wheel  8806  4 23 15:05 sbin
drwxr-xr-x   66 root wheel  2244 11 28 17:29 share


755を、変更するのと、グループの変更。

sudo chmod 775 /usr/local
sudo chgrp admin /usr/local

upgrade したあと、update したら、エラーがでたので、対処。

Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
MBA20120331:~ guutara$ cd $(brew --prefix)
MBA20120331:local guutara$ git fetch origin
remote: Counting objects: 345, done.
remote: Compressing objects: 100% (162/162), done.
remote: Total 345 (delta 130), reused 345 (delta 130)
Receiving objects: 100% (345/345), 124.79 KiB | 109.00 KiB/s, done.
Resolving deltas: 100% (130/130), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      gh-pages   -> origin/gh-pages
 * [new branch]      go         -> origin/go
MBA20120331:local guutara$  git reset --hard origin/master
Checking out files: 100% (2295/2295), done.
HEAD is now at 355e06d Remove support for version "schemes", just pass version objects directly

MBA20120331:Versions guutara$ brew doctor
Your system is ready to brew.

GO Lang を弄ってみる こんにちはせかい (1)

GoCON 行くので、少しでも、弄っておく。

インストールから、こんにちは世界まで。。

Go言語のインストール - golang.jp

MBA20120331:golang guutara$ brew install go
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/go-1.2.2.lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring go-1.2.2.lion.bottle.tar.gz
==> Caveats
As of go 1.2, a valid GOPATH is required to use the `go get` command:
  http://golang.org/doc/code.html#GOPATH

`go vet` and `go doc` are now part of the go.tools sub repo:
  http://golang.org/doc/go1.2#go_tools_godoc

To get `go vet` and `go doc` run:
  go get code.google.com/p/go.tools/cmd/godoc
  go get code.google.com/p/go.tools/cmd/vet

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/usr/local/opt/go/libexec/bin

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
sh: find: command not found
🍺  /usr/local/Cellar/go/1.2.2: 115M
MBA20120331:golang guutara$ go run hellow.go 
hello, world


go install で、パッケージでやってみる。
パッケージにする為に、goの作業用ディレクトリにsrc/helloを作り、ソースを配置した。
$GOPATH なしだと、エラーになった。
$GOPATH 設定して、無事作成完了。
$GOROOT は、なしでいけた。

MBA20120331:bin guutara$ mkdir -p ~/golang/src/hello
MBA20120331:bin guutara$ ls ~/golang/src/hello/
hellow.go
MBA20120331:bin guutara$ echo $GOPATH

MBA20120331:bin guutara$ go install hello
can't load package: package hello: cannot find package "hello" in any of:
	/usr/local/Cellar/go/1.2.2/libexec/src/pkg/hello (from $GOROOT)
	($GOPATH not set)
MBA20120331:bin guutara$ export GOPATH=/Users/guutara/golang
MBA20120331:bin guutara$ echo $GOPATH
/Users/guutara/golang
MBA20120331:bin guutara$ go install hello
MBA20120331:bin guutara$ ls $GOPATH/bin
hello
MBA20120331:bin guutara$ /Users/guutara/golang/bin/hello 
hello, こんにちは世界