2017年12月16日土曜日

前向いて仕事してたら転職できたよ

これは転職Adventカレンダー16日目の記事です。
転職 Advent Calendar 2017

バタバタしていてた当日の終わりがけの更新となってしまいました。申し訳ありません。。。
書いては書き直し、書いては書き直しを繰り返し、時間切れで書きたいことの半分くらいしか書けず、推敲もできておらず自己嫌悪中です。。。

自分自身、今年転職した身なので、記録するってくらいの軽い気持ちでAdventカレンダーに登録してみました。


■ダチョウ大臣とは
九州出身の30代。妻ちゃんとお子がいるサラリーマン。
物事あまり考えずに生きてきて、今ここにいます。
零細ブラックIT企業から某外資系企業に転職(一応エンジニアです)


■経歴について
・大学を半年留年して卒業(スポーツや運動、健康が専攻。しょぼいですが十種競技とかしてました。)。
・地方都市の自転車タクシーの立ち上げメンバーのお仕事。
・とある理由で地方都市の中小企業に入社(ソフトウェア開発会社)。OJTの開発プロジェクトで心折れる。
・転勤で上京。某Sierが販売する金融機関向けパッケージのサービスサポートに参画。
・大手銀行のメッセージ交換・決済システムの部署に派遣。
・妻ちゃんと出会い付き合う。
・在職中にとある理由で会社倒産→上長の知り合いの会社に所属をスライド。
・倒産で会社の寮が廃止されたので妻ちゃんと同棲する。
・サービスサポート参画時の知り合いに引き抜かれてサービスサポートに出戻り。
・妻ちゃんと結婚する。
・会社に色々と問題があり、キャリアや生活に不安が募る。
・お子が生まれる。決定的なことがあり、転職活動を行う。
・ご縁あって今の会社に入社。社会人になって一番楽しい時期が来ている所。


■転職のきっかけについて
会社がブラックなことと、社長の考え方と合わない、クソ性格の悪いバカ社員が同じチームにいたこと、上位会社のお局様リーダーがクソだったこと、キャリアアップ・給料アップが望めないこと。それらがきっかけです。
多くは書きませんが、社員の無知に漬け込み法は無視する、パワハラ、えこひいき等々。よくある話ですね。

今だから言えることですが、法を無視する会社はもちろん悪いけど、分かっていながら残り続ける人も自己責任だよなと思いました。
だって辞めることもできれば違う会社選択することもできるから。

あと法に関しても無知は罪。おかしいと思ったら関係機関に相談するなり、無料法律相談に行って確認すべき。
転職前の自分に説教したいです。
ブラック企業に勤めてる人、我慢する必要はないので転職しましょう。
感情的ではなく計画的に。


■自分が転職できた理由
今回私が転職できたのは、アプリケーションサーバやDB等、パッケージを構成していたミドル・インフラの基本的なアーキテクチャを一通りざっくりと理解していたこと、狭すぎるのですが業務知識を持っていたこと(私の場合は中央銀行に口座を持った金融機関の決済業務)、信頼、あとは運だと思います。

参画していたサービスサポートの仕事ですが、通算8年位やっていました。
所謂サポートセンターというやつです。
仕事はエンドユーザ・システム担当・ベンダーからの問い合わせの一次対応が主で、パッケージの仕様確認、障害時の窓口、カスタマイズ要件の受付・ヒアリング、自分たちが実機確認で使用する環境の管理等です。

特に問い合わせの対応は「パッケージについて調査を行う」のみで、「構成しているミドル・インフラの調査は行わない」という謎の方針でした。
なので、「ミドルは知らない、分からない、関係ない」というマインドで仕事をしている人が大半でした。
昔は私もその中の一人でした。

とは言え、検証環境をある程度自由に使えることが出来たのでAIX、RHEL、WMQ、OracleDB、WASを触れることと、またインターネットが使える現場なので調べたり学ぼうと思えば学べる環境は用意されていました。

いつ頃かは忘れましたが、興味本位でミドル・インフラの各種マニュアルやサポートページを見たり、ログを見たりと一歩突っ込んで自分なりに調査したり、調べた結果について認識に齟齬がないが開発担当者に質問するようになっってから色々と変化がありました。

システムの振る舞いが予想でき、問題が起きている処理の当たりがつくようになる、ログ出力結果から該当のプログラムの処理の詳細を追って仕様書と突合するといったことができるようになりました。
開発チームの方にもよく質問させていただき、最近のトレンドの技術について感想を言い合える関係を作れました。

また、パッケージだけでなく、中央銀行側のシステムの仕様にも興味が出ていわゆる接続仕様書や利用細則などを読み込み、金融機関のエンドユーザやベンダーとの会話も仕事として楽しめるようになりました。
それまでは何を言ってるのか訳がわかりませんでしたから(^_^;)

私の振る舞いも変わりました。障害やバク対応であれば、よりエンドユーザに寄り添い、だけど開発側の都合も鑑み、その中で落としどころをどう調整するのかという点に注力しました。
あくまでもユーザーよりなのはお客様に対するサービスサポートだから。その軸はブレないように心がけていました。

お陰様で、中でも外にも自信を持って仕事を行えるようになり、関係者から信頼を得ることができました。



そこから話は飛んでしまうのですが、転職で今の会社の面接を受けた際、サポートしていたユーザ企業がクライアントとのことで、そこのインフラ部門に要員を追加提案したいという状況で人を探しているとのことでした。
構築はできないけど話はできるしキャッチアップもできると自信を持って回答した所、無事採用されました。

その後ユーザー企業との面談では、なんとサポートしていたときの窓口の方が面接担当という奇跡的な状況で、上司の方に私は信頼できると上申していただけ、今は無事にその現場に参画しています。

今回、どちらかという末端と言われる仕事からキャリアアップできたのは、指示された仕事を思考停止してやるのではなく、興味を持ってやる、軸を持ってやる、当たり前かもしれないけどその2つでした。
同じような状況でキャリアアップできないと思っている人がいたら、まずは今やってる仕事を一歩踏み込んでやっていきましょう、自分が変わらなきゃそれから先の自分は変わらないよ、とお伝えしたいです。

愚痴だけ言って過ごしても何も変わらない、前向いて興味持って仕事して、次の職場でも前向いていくつもりで臨めば、道は切り開けることを実体験できました。

ブラック企業にお勤めの方、そこで自分をすり減らしてももったいないだけです。法を守ってる会社に転職しましょう。
まともに評価されない方、評価基準を明確にしている会社に転職しましょう。

訴えても会社はそう簡単に変わらないです。訴えても会社が受けるダメージは少ないです。訴えるくらいならまずは転職しましょう。
自分の生活基盤整えてからでも遅くないです。ちなみに、私は転職してストレスから開放された途端、訴える時間や労力がもったいなくなり、そういったことを考えるのを辞めました。

今のところ、お給料も社会的な安定も得られたので、頑張ってた当時の自分を褒めたいです。
まとまりなく、本当にスミマセン。これ落書きレベルだな。。。

明日は転職に成功した、私以上に高みを目指しているインフラガール『ぽんで』さんです!

若手インフラエンジニアの転職活動

それではでは!

2017年8月19日土曜日

docker pushでレジストリ登録、docker searchでレジストリを検索

[root@localhost ~]# docker push hogehogeRegistry/httpd
The push refers to a repository [docker.io/hogehogeRegistry/httpd]
9a6080c5a748: Pushed
5f70bf18a086: Layer already exists
8d12f3483b2e: Pushing [===============>                                   ] 63.28 MB/203.1 MB
8d12f3483b2e: Pushed
ver1.0: digest: sha256:e83b5b43bc0addd182e8faa79ca6177b9c0764ccd23119a4a459fb3d280e8406 size: 1153
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker serch hogehogeRegistry/httpd
docker: 'serch' is not a docker command.
See 'docker --help'.
[root@localhost ~]# docker search hogehogeRegistry/httpd
INDEX       NAME                                  DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/httpd                       The Apache HTTP Server Project                  1203      [OK]
docker.io   docker.io/hypriot/rpi-busybox-httpd   Raspberry Pi compatible Docker Image with ...   36
docker.io   docker.io/centos/httpd                                                                14                   [OK]
docker.io   docker.io/armhf/httpd                 The Apache HTTP Server Project                  8
docker.io   docker.io/macadmins/netboot-httpd     use in combination with bruienne/bsdpy          4                    [OK]
docker.io   docker.io/centos/httpd-24-centos7     Apache HTTP 2.4 Server                          2
docker.io   docker.io/lolhens/httpd               Apache httpd 2 Server                           2                    [OK]
docker.io   docker.io/i386/httpd                  The Apache HTTP Server Project                  1
docker.io   docker.io/lead4good/httpd-fpm         httpd server which connects via fcgi proxy...   1                    [OK]
docker.io   docker.io/amd64/httpd                                                                 0
docker.io   docker.io/antoineco/httpd             Extra OS variants for the official HTTPd i...   0                    [OK]
docker.io   docker.io/childsb/httpd                                                               0
docker.io   docker.io/dockerpinata/httpd                                                          0
docker.io   docker.io/efrecon/httpd               A micro-sized httpd. Start serving files i...   0                    [OK]
docker.io   docker.io/interferex/httpd            Simple HTTPd Server + TC Rate Limiting          0                    [OK]
docker.io   docker.io/jbpt/httpd                                                                  0                    [OK]
docker.io   docker.io/manageiq/httpd              Container with httpd, built on CentOS for ...   0                    [OK]
docker.io   docker.io/manasip/httpd                                                               0
docker.io   docker.io/objectstyle/httpd           ObjectStyle HTTPD Image                         0                    [OK]
docker.io   docker.io/openbucks/httpd                                                             0
docker.io   docker.io/ppc64le/httpd               The Apache HTTP Server Project                  0
docker.io   docker.io/publici/httpd               httpd:latest                                    0                    [OK]
docker.io   docker.io/publicisworldwide/httpd     The Apache httpd webserver.                     0                    [OK]
docker.io   docker.io/trollin/httpd                                                               0
docker.io   docker.io/visualops/httpd                                                             0
[root@localhost ~]# docker search hogehogeRegistry
INDEX       NAME                     DESCRIPTION   STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/hogehogeRegistry/httpd                 0
[root@localhost ~]#

docker cpでコンテナ上のファイルをホスト側にコピーする

[root@localhost sysconfig]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS              PORTS                  NAMES
0addec887dca        yosizo/httpd:ver1.0   "/bin/bash"         34 minutes ago      Up 34 minutes       0.0.0.0:8000->80/tcp   web01
[root@localhost sysconfig]# docker cp web01:/var/log/httpd /tmp
[root@localhost sysconfig]# ls -la /tmp/httpd
合計 12
drwx------.  2 root root   41  8月 19 11:29 .
drwxrwxrwt. 20 root root 4096  8月 19 12:04 ..
-rw-r--r--.  1 root root  422  8月 19 11:31 access_log
-rw-r--r--.  1 root root  476  8月 19 11:31 error_log
[root@localhost sysconfig]#

2017年8月18日金曜日

コンテナ上でhttpdを起動・ブラウザでアクセスしてみる

[root@localhost sysconfig]# docker run -it -p 8000:80 --name web01 yosizo/httpd;ver1.0 /bin/bash
Unable to find image 'yosizo/httpd:latest' locally
Trying to pull repository docker.io/yosizo/httpd ...
Pulling repository docker.io/yosizo/httpd
/usr/bin/docker-current: Tag latest not found in repository docker.io/yosizo/httpd.
See '/usr/bin/docker-current run --help'.
bash: ver1.0: コマンドが見つかりませんでした...
[root@localhost sysconfig]# docker run -it -p 8000:80 --name web01 yosizo/httpd:ver1.0 /bin/bash
[root@0addec887dca /]#
[root@0addec887dca /]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 02:26 ?        00:00:00 /bin/bash
root         13      1  0 02:26 ?        00:00:00 ps -ef
[root@0addec887dca /]# ls -l /var/www/html/
total 0
[root@0addec887dca /]# touch /var/www/html/index.html
[root@0addec887dca /]# vi /var/www/html/index.html
<h1>Hello,Docker/<h1>
~
"/var/www/html/index.html" 1L, 22C written
[root@0addec887dca /]# cat /var/www/html/index.html
<h1>Hello,Docker/<h1>
[root@0addec887dca /]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2 for ServerName
                                                           [  OK  ]
[root@0addec887dca /]#
[root@localhost sysconfig]#

→ブラウザからアクセスしてみると表示された。


docker rmでコンテナを削除する

[root@localhost sysconfig]# docker ps -a
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS                     PORTS               NAMES
956ebd5d66b4        enakai00/centos:centos6   "/bin/bash"         26 hours ago        Exited (0) 6 minutes ago                       centos01
[root@localhost sysconfig]#
[root@localhost sysconfig]# docker rm centos01
centos01
[root@localhost sysconfig]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost sysconfig]#

docker commitによるスナップショットの複製と新リポジトリーの作成

 docker commit centos01 yosizo/httpd:ver1.0
 docker commit [イメージ名] [リポジトリ名:タグ名]
→commitサブコマンドで対象のイメージを指定、作成するリポジトリ名を指定

[root@localhost sysconfig]# docker attach centos01
[root@956ebd5d66b4 /]#
[root@956ebd5d66b4 /]# exit
exit
[root@localhost sysconfig]# docker ps -a
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS                     PORTS               NAMES
956ebd5d66b4        enakai00/centos:centos6   "/bin/bash"         26 hours ago        Exited (0) 5 seconds ago                       centos01
[root@localhost sysconfig]#
[root@localhost sysconfig]# docker commit centos01 yosizo/httpd:ver1.0
sha256:24a55adfc23e9963b2771a0acfae076954c26f0d1b841202e0ada476efaeadde
[root@localhost sysconfig]#
[root@localhost sysconfig]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
yosizo/httpd                ver1.0              24a55adfc23e        8 seconds ago       267.7 MB
docker.io/enakai00/centos   centos6             b8c94c5d2d7c        2 years ago         203.1 MB
docker.io/enakai00/centos   centos7             3bd78cf8ed76        2 years ago         172.2 MB
docker.io/enakai00/centos   latest              3bd78cf8ed76        2 years ago         172.2 MB
[root@localhost sysconfig]#
[root@localhost sysconfig]# docker images yosizo/httpd:ver1.0
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
yosizo/httpd        ver1.0              24a55adfc23e        46 seconds ago      267.7 MB
[root@localhost sysconfig]#

docker stop,start,attach:コンテナの停止/起動/アクセスする

[root@localhost sysconfig]# docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
956ebd5d66b4        enakai00/centos:centos6   "/bin/bash"         26 hours ago        Up 12 minutes                           centos01
[root@localhost sysconfig]# docker stop centos01
centos01
[root@localhost sysconfig]# docker ps -a
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS                       PORTS               NAMES
956ebd5d66b4        enakai00/centos:centos6   "/bin/bash"         26 hours ago        Exited (137) 3 seconds ago                       centos01
[root@localhost sysconfig]#
[root@localhost sysconfig]# docker start centos01
centos01
[root@localhost sysconfig]# docker attach centos01
[root@956ebd5d66b4 /]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 02:11 ?        00:00:00 /bin/bash
root         13      1  0 02:11 ?        00:00:00 ps -ef
[root@956ebd5d66b4 /]#

コンテナのOSにhttpdをインストールする

[root@956ebd5d66b4 /]# yum -y install httpd
Loaded plugins: fastestmirror
Setting up Install Process
base                                                                                                                                                 | 3.7 kB     00:00
base/primary_db                                                                                                                                      | 4.7 MB     00:04
extras                                                                                                                                               | 3.4 kB     00:00
extras/primary_db                                                                                                                                    |  29 kB     00:00
updates                                                                                                                                              | 3.4 kB     00:00
updates/primary_db                                                                                                                                   | 2.5 MB     00:02
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-60.el6.centos.5 will be installed
--> Processing Dependency: httpd-tools = 2.2.15-60.el6.centos.5 for package: httpd-2.2.15-60.el6.centos.5.x86_64
--> Processing Dependency: system-logos >= 7.92.1-1 for package: httpd-2.2.15-60.el6.centos.5.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-60.el6.centos.5.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-60.el6.centos.5.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-60.el6.centos.5.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-60.el6.centos.5.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package httpd-tools.x86_64 0:2.2.15-60.el6.centos.5 will be installed
---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed
---> Package redhat-logos.noarch 0:60.0.14-12.el6.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================
 Package                                   Arch                               Version                                             Repository                           Size
============================================================================================================================================================================
Installing:
 httpd                                     x86_64                             2.2.15-60.el6.centos.5                              updates                             836 k
Installing for dependencies:
 apr                                       x86_64                             1.3.9-5.el6_2                                       base                                123 k
 apr-util                                  x86_64                             1.3.9-3.el6_0.1                                     base                                 87 k
 apr-util-ldap                             x86_64                             1.3.9-3.el6_0.1                                     base                                 15 k
 httpd-tools                               x86_64                             2.2.15-60.el6.centos.5                              updates                              80 k
 mailcap                                   noarch                             2.1.31-2.el6                                        base                                 27 k
 redhat-logos                              noarch                             60.0.14-12.el6.centos                               base                                 15 M

Transaction Summary
============================================================================================================================================================================
Install       7 Package(s)

Total download size: 16 M
Installed size: 19 M
Downloading Packages:
(1/7): apr-1.3.9-5.el6_2.x86_64.rpm                                                                                                                  | 123 kB     00:00
(2/7): apr-util-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                           |  87 kB     00:00
(3/7): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                      |  15 kB     00:00
(4/7): httpd-2.2.15-60.el6.centos.5.x86_64.rpm                                                                                                       | 836 kB     00:00
(5/7): httpd-tools-2.2.15-60.el6.centos.5.x86_64.rpm                                                                                                 |  80 kB     00:00
(6/7): mailcap-2.1.31-2.el6.noarch.rpm                                                                                                               |  27 kB     00:00
(7/7): redhat-logos-60.0.14-12.el6.centos.noarch.rpm                                                                                                 |  15 MB     00:06
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                       2.1 MB/s |  16 MB     00:07
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 Package: centos-release-6-6.el6.centos.12.2.x86_64 (@CentOS/$releasever)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : apr-1.3.9-5.el6_2.x86_64                                                                                                                                 1/7
  Installing : apr-util-1.3.9-3.el6_0.1.x86_64                                                                                                                          2/7
  Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                                                                                                                     3/7
  Installing : httpd-tools-2.2.15-60.el6.centos.5.x86_64                                                                                                                4/7
  Installing : mailcap-2.1.31-2.el6.noarch                                                                                                                              5/7
  Installing : redhat-logos-60.0.14-12.el6.centos.noarch                                                                                                                6/7
  Installing : httpd-2.2.15-60.el6.centos.5.x86_64                                                                                                                      7/7
  Verifying  : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                                                                                                                     1/7
  Verifying  : apr-1.3.9-5.el6_2.x86_64                                                                                                                                 2/7
  Verifying  : redhat-logos-60.0.14-12.el6.centos.noarch                                                                                                                3/7
  Verifying  : httpd-2.2.15-60.el6.centos.5.x86_64                                                                                                                      4/7
  Verifying  : mailcap-2.1.31-2.el6.noarch                                                                                                                              5/7
  Verifying  : apr-util-1.3.9-3.el6_0.1.x86_64                                                                                                                          6/7
  Verifying  : httpd-tools-2.2.15-60.el6.centos.5.x86_64                                                                                                                7/7

Installed:
  httpd.x86_64 0:2.2.15-60.el6.centos.5

Dependency Installed:
  apr.x86_64 0:1.3.9-5.el6_2       apr-util.x86_64 0:1.3.9-3.el6_0.1              apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1    httpd-tools.x86_64 0:2.2.15-60.el6.centos.5
  mailcap.noarch 0:2.1.31-2.el6    redhat-logos.noarch 0:60.0.14-12.el6.centos

Complete!
[root@956ebd5d66b4 /]#

/etc/sysconfig/dockerのオプション追加

/etc/sysconfig/dockerのオプション追加
コンテナイメージに対するディスク性能の最適化が行われていないことに対する、警告メッセージの抑止対応とのこと。

[root@localhost sysconfig]# ls -l docker
-rw-r--r--. 1 root root 2111  8月 19 10:47 docker
[root@localhost sysconfig]# cat /etc/sysconfig/docker
# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
#OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --storage-opt dm.no_warn_on_loop_devices=true'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

# If you want to add your own registry to be used for docker search and docker
# pull use the ADD_REGISTRY option to list a set of registries, each prepended
# with --add-registry flag. The first registry added will be the first registry
# searched.
#ADD_REGISTRY='--add-registry registry.access.redhat.com'

# If you want to block registries from being used, uncomment the BLOCK_REGISTRY
# option and give it a set of registries, each prepended with --block-registry
# flag. For example adding docker.io will stop users from downloading images
# from docker.io
# BLOCK_REGISTRY='--block-registry'

# If you have a registry secured with https but do not have proper certs
# distributed, you can tell docker to not look for full authorization by
# adding the registry to the INSECURE_REGISTRY line and uncommenting it.
# INSECURE_REGISTRY='--insecure-registry'

# On an SELinux system, if you remove the --selinux-enabled option, you
# also need to turn on the docker_transition_unconfined boolean.
# setsebool -P docker_transition_unconfined 1

# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp

# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false
#

# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest
[root@localhost sysconfig]#

2017年8月17日木曜日

docker attachコマンドで起動しているコンテナを使用する

コンテナ「centos01」にアタッチして使用するというイメージ。

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
956ebd5d66b4        enakai00/centos:centos6   "/bin/bash"         17 minutes ago      Up 17 minutes                           centos01
[root@localhost ~]#
[root@localhost ~]# docker attach centos01
[root@956ebd5d66b4 /]#

docker psコマンドで稼働中のコンテナを確認する

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
956ebd5d66b4        hogehogeRepository/centos:centos6   "/bin/bash"         17 minutes ago      Up 17 minutes                           centos01
[root@localhost ~]#

コンテナからホストOSに抜けるためにctrl+P+Qを押す

コンテナからホストOSに抜けるためにctrl+P+Qを押す

[root@956ebd5d66b4 /]#
[root@956ebd5d66b4 /]#  <==(ここでctrl+P+Qを押すと抜けれる)
[root@localhost ~]#

コンテナの中のネットワーク設定状況

[root@956ebd5d66b4 /]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 02:42:AC:11:00:02
          inet addr:172.17.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2512 (2.4 KiB)  TX bytes:648 (648.0 b)

[root@956ebd5d66b4 /]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.17.0.1      0.0.0.0         UG    0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0
[root@956ebd5d66b4 /]#

docker run:docker runコマンドでリポジトリ内のイメージのコンテナを起動する

docker runコマンドでリポジトリ内のイメージのコンテナを起動する
docker run -it --name centos01 [使用するイメージ名(リポジトリ名:イメージ名)]
→-itオプションはおまじないとして基本的にはつけておく。
→--nameオプションは起動するコンテナ名を指定する。つけないと適当な名前が付与されるらしい。

コンテナの起動と併せてbashを起動することで、起動したコンテナにて操作を行える。

[root@localhost ~]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
docker.io/hogehogeRepository/centos   centos6             b8c94c5d2d7c        2 years ago         203.1 MB
docker.io/hogehogeRepository/centos   centos7             3bd78cf8ed76        2 years ago         172.2 MB
docker.io/hogehogeRepository/centos   latest              3bd78cf8ed76        2 years ago         172.2 MB
[root@localhost ~]# docker run -it --name centos01 hogehogeRepository/centos:centos6 /bin/bash
[root@956ebd5d66b4 /]#
[root@956ebd5d66b4 /]# cat /etc/centos-release
CentOS release 6.6 (Final)
[root@956ebd5d66b4 /]# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/docker-253:0-50488737-d54959bdb29a05cb10a65d049b237a8e5aaaab33d9fc84f6c1de1c4890d3ab49
                       10G  250M  9.8G   3% /
[root@956ebd5d66b4 /]#
[root@956ebd5d66b4 /]#
[root@956ebd5d66b4 /]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 23:46 ?        00:00:00 /bin/bash
root         15      1  0 23:48 ?        00:00:00 ps -ef
[root@956ebd5d66b4 /]#

docker pullとdocker images:リポジトリのダウンロードとリポジトリ内のイメージの一覧表示

①リポジトリをpullサブコマンドでダウンロードしてくる
docker pull -a hogehogeRepository/centos

②ダウンロードしてきたリポジトリ内のイメージの一覧を出力する
docker images


実行例①
[root@localhost ~]# docker pull -a hogehogeRepository/centos
Trying to pull repository docker.io/hogehogeRepository/centos ...
centos6: Pulling from docker.io/hogehogeRepository/centos

a3ed95caeb02: Pull complete
dfabbb82181a: Pull complete
Digest: sha256:1422c5ba80430ae5899e40774bb3033e71cba5589d1163e04b1b801698e61127
centos7: Pulling from docker.io/hogehogeRepository/centos

a3ed95caeb02: Pull complete
a5b52df5865b: Pull complete
Digest: sha256:5871aecd08cd037002d42ebb92cfe11a78c93806ab2275a627bf4551cc638855
latest: Pulling from docker.io/hogehogeRepository/centos

a3ed95caeb02: Already exists
a5b52df5865b: Already exists
Digest: sha256:49ecd6397d1f23deb245d3e0332862d68a9d34bb1d030066ae6175b8e9540c34
[root@localhost ~]#


実行例②
[root@localhost ~]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
docker.io/hogehogeRepository/centos   centos6             b8c94c5d2d7c        2 years ago         203.1 MB
docker.io/hogehogeRepository/centos   centos7             3bd78cf8ed76        2 years ago         172.2 MB
docker.io/hogehogeRepository/centos   latest              3bd78cf8ed76        2 years ago         172.2 MB
[root@localhost ~]#

docker searchでリポジトリを検索する

docker searchでリポジトリを検索する時の実行例
docker search hogehogeRepository
→hogehogeRepositoryというリポジトリを検索。
→docker.ioはdockerHubを表現
→hogehogeRepository/centosはリポジトリを表現

[root@localhost ~]# docker search hogehogeRepository
INDEX       NAME                                               DESCRIPTION                               STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/hogehogeRepository/jupyter_tensorflow                                                        3                
docker.io   docker.io/hogehogeRepository/app                                                                       0                
docker.io   docker.io/hogehogeRepository/centos                          Sample CentOS repository for dockerbon.   0                
docker.io   docker.io/hogehogeRepository/dbs                                                                       0                
docker.io   docker.io/hogehogeRepository/eplite                                                                    0                
docker.io   docker.io/hogehogeRepository/epmysql                                                                   0                
docker.io   docker.io/hogehogeRepository/fedora                          Sample fedora repository for dockerbon.   0                
docker.io   docker.io/hogehogeRepository/httpd                                                                     0                
docker.io   docker.io/hogehogeRepository/ostools                                                                   0                
docker.io   docker.io/hogehogeRepository/test-httpd                                                                0                
docker.io   docker.io/hogehogeRepository/vcp_base                                                                  0                
docker.io   docker.io/hogehogeRepository/web                                                                       0                
docker.io   docker.io/yacchin1205/hogehogeRepository-tensorflow-kernel                                             0                
[root@localhost ~]#

dockerコマンドのmanページ、サブコマンドの確認

[root@localhost ~]# man docker

DOCKER(1)                                               APRIL 2014                                              DOCKER(1)

NAME
       docker - Docker image and container command line interface

SYNOPSIS
       docker [OPTIONS] COMMAND [arg...]

       docker daemon [--help|...]

       docker [--help|-v|--version]

DESCRIPTION
       is a client for interacting with the daemon (see dockerd(8)) through the CLI.

       The  Docker  CLI  has  over 30 commands. The commands are listed below and each has its own man page which explain
       usage and arguments.

       To see the man page for a command run man docker <command>.

OPTIONS
       --help
         Print usage statement

       --config=""
         Specifies the location of the Docker client configuration files. The default is ' /.docker'.

       -D, --debug=true|false
         Enable debug mode. Default is false.

       -H, --host=[unix:///var/run/docker.sock]: tcp://[host]:[port][path] to bind or unix://[/path/to/socket] to use.
         The socket(s) to bind to in daemon mode specified using one or more
         tcp://host:port/path, unix:///path/to/socket, fd://* or fd://socketfd.
         If the tcp port is not specified, then it will default to either 2375 when
         --tls is off, or 2376 when --tls is on, or --tlsverify is specified.

       -l, --log-level="debug|info|warn|error|fatal"
         Set the logging level. Default is info.

       --tls=true|false
         Use TLS; implied by --tlsverify. Default is false.

       --tlscacert= /.docker/ca.pem
         Trust certs signed only by this CA.

       --tlscert= /.docker/cert.pem
         Path to TLS certificate file.

       --tlskey= /.docker/key.pem
         Path to TLS key file.

       --tlsverify=true|false
         Use TLS and verify the remote (daemon: verify client, client: verify daemon).
[root@localhost ~]#man dokcer-run
DOCKER(1)                                               JUNE 2014                                               DOCKER(1)

NAME
       docker-run - Run a command in a new container

SYNOPSIS
       docker  run  [-a|--attach[=[]]]  [--add-host[=[]]]  [--blkio-weight[=[BLKIO-WEIGHT]]] [--blkio-weight-device[=[]]]
       [--cpu-shares[=0]]  [--cap-add[=[]]]   [--cap-drop[=[]]]   [--cgroup-parent[=CGROUP-PATH]]   [--cidfile[=CIDFILE]]
       [--cpu-period[=0]]  [--cpu-quota[=0]]  [--cpuset-cpus[=CPUSET-CPUS]]  [--cpuset-mems[=CPUSET-MEMS]]  [-d|--detach]
       [--detach-keys[=[]]] [--device[=[]]] [--device-read-bps[=[]]] [--device-read-iops[=[]]]  [--device-write-bps[=[]]]
       [--device-write-iops[=[]]] [--dns[=[]]] [--dns-opt[=[]]] [--dns-search[=[]]] [-e|--env[=[]]] [--entrypoint[=ENTRY‐
       POINT]] [--env-file[=[]]] [--expose[=[]]] [--group-add[=[]]]  [-h|--hostname[=HOSTNAME]]  [--help]  [-i|--interac‐
       tive]  [--ip[=IPv4-ADDRESS]]  [--ip6[=IPv6-ADDRESS]]  [--ipc[=IPC]] [--isolation[=default]] [--kernel-memory[=KER‐
       NEL-MEMORY]]  [-l|--label[=[]]]  [--label-file[=[]]]  [--link[=[]]]   [--link-local-ip[=[]]]   [--log-driver[=[]]]
       [--log-opt[=[]]]  [-m|--memory[=MEMORY]] [--mac-address[=MAC-ADDRESS]] [--memory-reservation[=MEMORY-RESERVATION]]
       [--memory-swap[=LIMIT]] [--memory-swappiness[=MEMORY-SWAPPINESS]] [--name[=NAME]]  [--network-alias[=[]]]  [--net‐
       work[="bridge"]] [--oom-kill-disable] [--oom-score-adj[=0]] [-P|--publish-all] [-p|--publish[=[]]] [--pid[=[PID]]]
       [--userns[=[]]] [--pids-limit[=PIDS_LIMIT]] [--privileged]  [--read-only]  [--restart[=RESTART]]  [--rm]  [--secu‐
       rity-opt[=[]]]     [--storage-opt[=[]]]     [--stop-signal[=SIGNAL]]     [--shm-size[=[]]]    [--sig-proxy[=true]]
       [--sysctl[=[]]] [-t|--tty] [--tmpfs[=[CONTAINER-DIR[:<OPTIONS>]]] [-u|--user[=USER]] [--ulimit[=[]]]  [--uts[=[]]]
       [-v|--volume[=[[HOST-DIR:]CONTAINER-DIR[:OPTIONS]]]]        [--volume-driver[=DRIVER]]       [--volumes-from[=[]]]
       [-w|--workdir[=WORKDIR]] IMAGE [COMMAND] [ARG...]

DESCRIPTION
       Run a process in a new container. docker run starts a process with its own file system, its  own  networking,  and
       its  own isolated process tree. The IMAGE which starts the process may define defaults related to the process that
       will be run in the container, the networking to expose, and more, but docker run gives final control to the opera‐
       tor or administrator who starts the container from the image. For that reason docker run has more options than any
       other Docker command.

       If the IMAGE is not already loaded then docker run will pull the IMAGE,  and  all  image  dependencies,  from  the
       repository in the same way running docker pull IMAGE, before it starts the container from that image.

OPTIONS
       -a, --attach=[]
          Attach to STDIN, STDOUT or STDERR.

       In  foreground  mode (the default when -d is not specified), docker run can start the process in the container and
       attach the console to the process's standard input, output, and standard error. It can even pretend to  be  a  TTY
       (this  is  what  most commandline executables expect) and pass along signals. The -a option can be set for each of
       stdin, stdout, and stderr.

       --add-host=[]
          Add a custom host-to-IP mapping (host:ip)

       Add a line to /etc/hosts. The format is hostname:ip.  The --add-host option can be set multiple times.

       --blkio-weight=0
          Block IO weight (relative weight) accepts a weight value between 10 and 1000.

       --blkio-weight-device=[]
          Block IO weight (relative device weight, format: DEVICE_NAME:WEIGHT).



dockerインストール

OS:centos7
前提:yum -y updateを実行済み

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl mask firewalld.service
Created symlink from /etc/systemd/system/firewalld.service to /dev/null.
[root@localhost ~]#
[root@localhost ~]# yum -y install docker
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ docker.x86_64 2:1.12.6-32.git88a4867.el7.centos を インストール
--> 依存性の処理をしています: docker-common = 2:1.12.6-32.git88a4867.el7.centos のパッケージ: 2:docker-1.12.6-32.git88a4867.el7.centos.x86_64
--> 依存性の処理をしています: docker-client = 2:1.12.6-32.git88a4867.el7.centos のパッケージ: 2:docker-1.12.6-32.git88a4867.el7.centos.x86_64
--> 依存性の処理をしています: oci-systemd-hook >= 1:0.1.4-9 のパッケージ: 2:docker-1.12.6-32.git88a4867.el7.centos.x86_64
--> 依存性の処理をしています: oci-register-machine >= 1:0-3.10 のパッケージ: 2:docker-1.12.6-32.git88a4867.el7.centos.x86_64
--> 依存性の処理をしています: container-selinux >= 2:2.12-2 のパッケージ: 2:docker-1.12.6-32.git88a4867.el7.centos.x86_64
--> 依存性の処理をしています: skopeo-containers のパッケージ: 2:docker-1.12.6-32.git88a4867.el7.centos.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ container-selinux.noarch 2:2.19-2.1.el7 を インストール
---> パッケージ docker-client.x86_64 2:1.12.6-32.git88a4867.el7.centos を インストール
---> パッケージ docker-common.x86_64 2:1.12.6-32.git88a4867.el7.centos を インストール
---> パッケージ oci-register-machine.x86_64 1:0-3.11.gitdd0daef.el7 を インストール
---> パッケージ oci-systemd-hook.x86_64 1:0.1.7-4.gite533efa.el7 を インストール
---> パッケージ skopeo-containers.x86_64 1:0.1.20-2.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

=============================================================================================================================
 Package                          アーキテクチャー   バージョン                                     リポジトリー        容量
=============================================================================================================================
インストール中:
 docker                           x86_64             2:1.12.6-32.git88a4867.el7.centos              extras              14 M
依存性関連でのインストールをします:
 container-selinux                noarch             2:2.19-2.1.el7                                 extras              28 k
 docker-client                    x86_64             2:1.12.6-32.git88a4867.el7.centos              extras             3.2 M
 docker-common                    x86_64             2:1.12.6-32.git88a4867.el7.centos              extras              77 k
 oci-register-machine             x86_64             1:0-3.11.gitdd0daef.el7                        extras             1.0 M
 oci-systemd-hook                 x86_64             1:0.1.7-4.gite533efa.el7                       extras              30 k
 skopeo-containers                x86_64             1:0.1.20-2.el7                                 extras             7.8 k

トランザクションの要約
=============================================================================================================================
インストール  1 パッケージ (+6 個の依存関係のパッケージ)

総ダウンロード容量: 19 M
インストール容量: 64 M
Downloading packages:
(1/7): container-selinux-2.19-2.1.el7.noarch.rpm                                                      |  28 kB  00:00:00
(2/7): oci-systemd-hook-0.1.7-4.gite533efa.el7.x86_64.rpm                                             |  30 kB  00:00:00
(3/7): skopeo-containers-0.1.20-2.el7.x86_64.rpm                                                      | 7.8 kB  00:00:00
(4/7): docker-common-1.12.6-32.git88a4867.el7.centos.x86_64.rpm                                       |  77 kB  00:00:00
(5/7): oci-register-machine-0-3.11.gitdd0daef.el7.x86_64.rpm                                          | 1.0 MB  00:00:01
(6/7): docker-client-1.12.6-32.git88a4867.el7.centos.x86_64.rpm                                       | 3.2 MB  00:00:02
(7/7): docker-1.12.6-32.git88a4867.el7.centos.x86_64.rpm                                              |  14 MB  00:00:39
-----------------------------------------------------------------------------------------------------------------------------
合計                                                                                         477 kB/s |  19 MB  00:00:39
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : 2:docker-common-1.12.6-32.git88a4867.el7.centos.x86_64                                       1/7
  インストール中          : 2:docker-client-1.12.6-32.git88a4867.el7.centos.x86_64                                       2/7
  インストール中          : 1:skopeo-containers-0.1.20-2.el7.x86_64                                                      3/7
  インストール中          : 1:oci-register-machine-0-3.11.gitdd0daef.el7.x86_64                                          4/7
  インストール中          : 2:container-selinux-2.19-2.1.el7.noarch                                                      5/7
  インストール中          : 1:oci-systemd-hook-0.1.7-4.gite533efa.el7.x86_64                                             6/7
Stopping containers...
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
"docker stop" requires at least 1 argument(s).
See 'docker stop --help'.

Usage:  docker stop [OPTIONS] CONTAINER [CONTAINER...]

Stop one or more running containers
  インストール中          : 2:docker-1.12.6-32.git88a4867.el7.centos.x86_64                                              7/7
  検証中                  : 2:docker-1.12.6-32.git88a4867.el7.centos.x86_64                                              1/7
  検証中                  : 1:oci-systemd-hook-0.1.7-4.gite533efa.el7.x86_64                                             2/7
  検証中                  : 2:container-selinux-2.19-2.1.el7.noarch                                                      3/7
  検証中                  : 2:docker-common-1.12.6-32.git88a4867.el7.centos.x86_64                                       4/7
  検証中                  : 1:oci-register-machine-0-3.11.gitdd0daef.el7.x86_64                                          5/7
  検証中                  : 1:skopeo-containers-0.1.20-2.el7.x86_64                                                      6/7
  検証中                  : 2:docker-client-1.12.6-32.git88a4867.el7.centos.x86_64                                       7/7

インストール:
  docker.x86_64 2:1.12.6-32.git88a4867.el7.centos

依存性関連をインストールしました:
  container-selinux.noarch 2:2.19-2.1.el7                       docker-client.x86_64 2:1.12.6-32.git88a4867.el7.centos
  docker-common.x86_64 2:1.12.6-32.git88a4867.el7.centos        oci-register-machine.x86_64 1:0-3.11.gitdd0daef.el7
  oci-systemd-hook.x86_64 1:0.1.7-4.gite533efa.el7              skopeo-containers.x86_64 1:0.1.20-2.el7

完了しました!
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker -v
Docker version 1.12.6, build 88a4867/1.12.6
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# systemctl start docker.service
[root@localhost ~]#