Understand images & containers of Docker
4798 ワード
Dockerを使用する前に、
Docker世界では container:シェルを剥がす最小化Linux. イメージ: ローカル検索 見つからない場合は、Docker Hubからimage をダウンロードします.は、 にロードする.
通常、
(Githubの利用者であれば、
Dockerのcontainerはどこですか?
containerの作成
ローカルcontainersの表示
containerステータスの表示
containerに接続
Dockerのイメージは何ですか?
docker run helloworld imageを実行
このときdockerは
このときの
docker imagesローカルのimagesを表示
まとめ
build & share
の開発環境にVagrantを使用します.各Vagrant package
は完全な仮想ホストであり、1つのpackage
には通常いくつかのGがある.いくつかのGのパッケージを共有して更新するのは高価なことです.Docker世界では
Vagrant
のpackage
をcontainers
&images
に分解し、この2つの概念がDocker世界全体を支えています.container
にロードされるソフトウェアです.docker run helloworld
を実行すると、docker
は次の3つのことをします.hello-world
ソフトウェアイメージimage
をcontainer
にロードし、run
通常、
docker-machine
を使用してcontainer
を管理し、docker
を使用してimage
を実行します.images
はDocker Hubによって共有される.(Githubの利用者であれば、
Docker Hub
を簡単に手に入れることができます.Docker Hub
についてはここでは紹介しません)Dockerのcontainerはどこですか?
container
は殻を剥いた、最も基礎的なLinuxです.Mac OSではdocker-machine
を使用してcontainer
を管理しています.containerの作成
dev
という名前のcontainer
:docker-machine create --driver virtualbox dev
を作成ローカルcontainersの表示
➜ mydockerbuild docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
default virtualbox Running tcp://192.168.99.101:2376
dev virtualbox Running tcp://192.168.99.100:2376
containerステータスの表示
➜ mydockerbuild docker-machine active
dev
➜ mydockerbuild docker-machine status dev
Running
containerに接続
➜ mydockerbuild docker-machine ssh dev
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.8.2, build master : aba6192 - Thu Sep 10 20:58:17 UTC 2015
Docker version 1.8.2, build 0a8c2e3
er@dev:~$ uname -a
Linux dev 4.0.9-boot2docker #1 SMP Thu Sep 10 20:39:20 UTC 2015 x86_64 GNU/Linux
Dockerのイメージは何ですか?
docker run helloworld imageを実行
このときdockerは
run
というhello-world
というアプリケーションで、次の結果を印刷します.➜ sts docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
535020c3e8ad: Pull complete
af340544ed62: Pull complete
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
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.
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:
このときの
hello-world
プログラムはdockerにおいてimage
となり、dockerによってcontainer
の上に置かれて実行される.docker imagesローカルのimagesを表示
➜ mydockerbuild docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker-whale latest 1935900e3705 5 hours ago 274 MB
ubuntu latest 91e54dfb1179 6 weeks ago 188.4 MB
hello-world latest af340544ed62 8 weeks ago 960 B
docker/whalesay latest fb434121fc77 4 months ago 247 MB
まとめ
images
&containers
はDockerの世界で最も基本的な概念です.image
はソフトウェアであり、container
はソフトウェアを実行するためのオペレーティングシステムである.Dockerの世界では、私たちはほとんどの時間をDockerのimages
と付き合っています.docker
は、git
と同様のメカニズムを使用してimages
を管理および共有し、docker
を使用してimages
を作成する場合、git
を使用する場合と同様である.Docker Hub
の存在は、Github
対git
の存在と同様に、docker images
の共有を非常に容易にする.