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

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

【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】 - プログラミングと旅と映画の日々