プログラミングと旅と映画の日々

普段はスマホ決済サービスの会社でバッグエンドを担当しているエンジニアです。プログラミングと趣味の映画、株、時々うどんに関してブログを書いていこうと思います。海外ドラマ、クロスバイクも好きです。

【Docker】Docker hubへのイメージのプッシュ方法【入門】

Docker hubへのイメージのpush 方法

f:id:takanori5:20181028132956p:plain
リポジトリにイメージを追加してみます。

pushするにはDocker hubにログインする必要あり。
以下のコマンドを実行

$ docker login
hodzumitakanori-no-MacBook-Air:imagebuild hodzumitakanori$ docker login
Authenticating with existing credentials...
Login Succeeded

Login Succeeded!!

docker hubのタグ付けのルール

/:<タグ名>
タグ名の指定を省略すると自動でlatestタグと判定される

$ docker tag docker-whale takanori5/docker-whale:ver1
$ docker images
REPOSITORY          TAG                   IMAGE ID            CREATED             SIZE
takanori5/docker-whale   ver1                  0c788d9552c9        5 days ago          277MB

tag付けできました。

ではdocker hubにpushしていきます。

docker push <docker ID>/<image名>:<タグ名>
$ docker push takanori5/docker-whale:ver1
The push refers to repository [docker.io/takanori5/docker-whale]
288eb47d521e: Pushed
5f70bf18a086: Mounted from docker/whalesay
d061ee1340ec: Mounted from docker/whalesay
d511ed9e12e1: Mounted from docker/whalesay
091abc5148e4: Mounted from docker/whalesay
b26122d57afa: Mounted from docker/whalesay
37ee47034d9b: Mounted from docker/whalesay
528c8710fd95: Mounted from docker/whalesay
1154ba695078: Mounted from docker/whalesay

ver1: digest: sha256:dd05678a4931ce83947b376e5ab0c39a632f80f8504a7072bfc7de2ff2ee7635 size: 2614

push できました。


アップできています。
f:id:takanori5:20181102144315p:plain

試しにローカルのイメージを削除した上でpullしてみましょう。

//削除
$ docker rmi -f 0c788d9552c9
Untagged: hoz/docker-whale:ver1
Untagged: docker-whale:latest
Untagged: takanori5/docker-whale:ver1
Untagged: takanori5/docker-whale@sha256:dd05678a4931ce83947b376e5ab0c39a632f80f8504a7072bfc7de2ff2ee7635
Deleted: sha256:0c788d9552c9375eb30546618e033a2cf7d72bc7b216aa9997b64fea2bcc612b
Deleted: sha256:e77d0b9fa75be179620913aad7f08dbea9b4374b183940fbd7463305f9f5517c

//結果確認
$ docker images
REPOSITORY          TAG                   IMAGE ID            CREATED             SIZE
hello-world         latest                4ab4c602aa5e        7 weeks ago         1.84kB
mysql               5.7.21                5195076672a7        7 months ago        371MB
nginx               1.13.9-alpine         537527661905        8 months ago        17.9MB
php                 7.2.2-fpm-alpine3.6   59d3e94a05b7        8 months ago        77.2MB
docker/whalesay     latest                6b362a9f73eb        3 years ago         247MB

//hubからpull
$ docker pull takanori5/docker-whale:ver1
ver1: Pulling from takanori5/docker-whale
e190868d63f8: Already exists
909cd34c6fd7: Already exists
0b9bfabab7c1: Already exists
a3ed95caeb02: Already exists
00bf65475aba: Already exists
c57b6bcc83e3: Already exists
8978f6879e2f: Already exists
8eed3712d2cf: Already exists
fa71efe4e5ff: Already exists
Digest: sha256:dd05678a4931ce83947b376e5ab0c39a632f80f8504a7072bfc7de2ff2ee7635

これでこのレポジトリにアクセスできるアカウント保持者は
誰でもこのイメージを取得できるようになりました!!

【Docker】Docker fileを使用したイメージの構築方法【入門】

Docker fileを使用したイメージの構築方法

f:id:takanori5:20181028132956p:plain
Docker fileを使用してイメージを構築することをイメージビルドと呼ぶ

docker fileからイメージをビルドするコマンド

docker build -t hoge .
-t hoge(タグ名を指定)/ . ビルドコンテキストを指定(この場合current directory)

current directory にあるDockerfileがビルドされる

イメージビルド時にビルドコンテキストのファイルはDockerデーモンに転送されるので重いファイルは置かないように注意。

【Docker】Docker imageとは何か【入門】

Docker imageとは何か

f:id:takanori5:20181028132956p:plain

Docker imageとは

コンテナ実行に必要なファイルをまとめたファイルシステム
(ファイル例:OSのライブラリやアプリケーションなど)
imageは階層構造でデータが管理されていて
角層をレイヤーと呼ばれる
例えば、dockerイメージにnginxをインストールするイメージを実行すれば
レイヤーが一層積まれる感じ。
そして一度作成したイメージのレイヤーは全て読み取り専用で
変更不可。
f:id:takanori5:20181028134840p:plain

dockerイメージを元にコンテナを起動すると
新たに新しく読み書き可能なコンテナレイヤーが作成される
ただし、過去のレイヤーは読み取り専用。
無駄なファイルがイメージに含まれないようにイメージを作成することが重要。

イメージが大きくなると
Dockerのメリットである軽量であるということが薄れる

Dockerのイメージ継承について

以下の図のようにベースとしたいイメージを元にして
アプリレイヤーを構築できたりします。
超便利!!
f:id:takanori5:20181028135542p:plain

同じDockerイメージを継承した場合のメリット
centOSのイメージを同一にして
上位のレイヤーはRuby用、MySQL用という風にすることで
レイヤーの重複を排除でき、無駄なファイルのインストールをしなくてもよくなります。
通信料も節約できますね。
f:id:takanori5:20181028135900p:plain

【Docker】Docker hubとは何か【入門】

Docker hubとは

f:id:takanori5:20181028132956p:plain

Docker hubはDockerのレジストリサービス

Dockerイメージの公開、検索、ダウンロードが可能

 

https://hub.docker.com/

 

試しにexploreをみると

色々なレポジトリがありますね

f:id:takanori5:20181028133655p:plain

 

hello worldを検索すると多くのレポジトリが出ます

f:id:takanori5:20181028134013p:plain

スラッシュで区切られていないものがオフィシャルのレポジトリです。

Docker社がレビューしてオフィシャル判定しているらしいです。

f:id:takanori5:20181028134024p:plain

 

tagでver管理も可能

f:id:takanori5:20181028134334p:plain

以下のようにtag指定でイメージの取得も可能

>|ruby|

$ docker run hello-world:latest

||<

 

【Docker】Dockerでhello wold【Docker】

Dockerでhello worldしてみる

f:id:takanori5:20181028132956p:plain
dockerを今更ながら学習し始めました。

まずはhello world

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

dockerコマンドをterminal上から打つと
dockerクライアント(terminal)はdockerデーモンに接続する
そこでhello wolrdのイメージを探す
PC上に存在しない場合、docker hubというdocker社が管理している場所に
ネットワークを経由して取得しにいく
次にdocker hub上にhello wold imageが見つかったら
hubからimageをダウンロードしPCに保存。
保存したイメージを元にコンテナを起動する。
同じイメージが存在する場合はPCから起動するため起動が早くなる

試しにもう一度docer run コマンドを実行します。

$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

docker run コマンドを紐解く

docker run コマンドでは以下の複数のコマンドが一括実行されている
image取得

docker pull

コンテナ作成

docker create

コンテナ起動

docker start

【Docker】Dockerでhello wold【Docker】 - プログラミングと旅と映画の日々

【映画】「あの頃、君を追いかけた」を観てきました【感想】

2018年の映画「あの頃、君を追いかけた」の感想

 こんにちは

 

今回は、台湾で大ヒットした映画「あの頃、君を追いかけた」

の日本版のリメイク作品を観てきました。

f:id:takanori5:20181007151840j:plain

齋藤飛鳥山田裕貴主演の作品です。

齋藤飛鳥さん、あまり知りませんでしたが

可愛いだけでなくて演技もかなり美味かったです。

誰もが認める美少女役でしたが

確かに引くほど美人でした..

調べて観たら日本とミャンマーのハーフらしいですね。

f:id:takanori5:20181007151952j:plain

 

山田裕貴はバカっぽい見た目なのであまり好きではありませんでしたが、

やんちゃな役の演技がかなりはまっていて

いい奴感も出ていて好きになりました。

f:id:takanori5:20181007152312j:plain

 

「あの頃、君を追いかけた」のあらすじ

台湾の人気作家ギデンズ・コーが自伝的小説を自ら映画化し、台湾で大ヒットを記録した同名作品の舞台を日本に移し、「HiGH&LOW」シリーズの山田裕貴、「乃木坂46」の齋藤飛鳥主演により再映画化。地方都市の高校に通う水島浩介は、クラスの仲間たちとバカなことばかりしながら、お気楽な高校生活を楽しんでいた。ある日、浩介の度を越した悪ふざけによって授業が中断。激怒した教師が浩介のお目付け役として任命したのが優等生の早瀬真愛だった。クラス一の優等生で真面目で堅い真愛を疎ましく思う浩介だったが、彼と4人の仲間たちにとって中学時代からの憧れの存在だった真愛に浩介の胸はざわつきはじめていた。

あの頃、君を追いかけた : 作品情報 - 映画.com

 

 「あの頃、君を追いかけた」の感想

高校時代から両想いだったにも関わらず、付き合うことなくお互い大学に進学します。

大学に進学してからもお互い好き同士なのになかなか上手くいかず…

そしてマナは別の人と結婚してストーリーは終わります。

モヤっとする終わり方ですがそれが現実味があり素敵でした。

こんな感じのストーリーをリアルで経験している人は結構いそう。

特に男性だとより共感できそうな話でした。

主演の二人が特にはまり役で、圧倒的な美少女役の齋藤飛鳥さんと、ヤンチャなバカの山田裕貴さんの演技が見事な作品でした。

 

原作も観たいです。

 

takanori5.hatenablog.com

【王子】王子でうどんの食べログ人気ランキング二位の名店「うどん屋 清」に行ってきました

うどん屋 清@王子店

こんばんは

 

今回は、私が住んでいる王子で

食べログ上位のうどん店である「うどん屋 清」に行ってまいりました。

 

知り合いの王子に本社を構える人材会社の社長にも

過去にオススメされており気になっていました。

一位の喜久家もきになるのでまた今度行きます!

f:id:takanori5:20181007223104p:plain

 

うどん屋

店頭はこんな感じ。小料理屋風ですね。

ちょっと一人だとかなり入りずらかったですが突撃しました。

f:id:takanori5:20181007203318j:image

 

肉つけうどん@680円

肉つけうどんが美味しそうだったので注文。

このお店は居酒屋利用が夜は多いイメージで

カウンター席の皆さんはお酒と天ぷらを嗜んでいました。

 

うどん

肉つけうどん

うどんのお味ですが程よいコシのあるうどんに

甘めのダシが美味しいです。

インパクトはないですが、品のあるうどんといった印象。

 

ここはうどんも手頃な価格なので

仕事帰りなどにふらっと食べるのに良さそうです。



 

takanori5.hatenablog.com