Windows10にDockerを導入する
Windows10でも、Dockerを使ってみましょう。
必要スペック
Windows10proが必要です。。。
インストール手順
①Docker Storeより、インストーラをダウンロード。
公式ドキュメントによれば、以下のコンポーネントが含まれます。
What the Docker for Windows install includes: The installation provides Docker Engine, Docker CLI client, Docker Compose, Docker Machine, and Kitematic.
②ダウンロードが完了したら、インストーラを起動します。指示に沿って、インストールを完了します。
③Hyper-Vを起動していない場合、
の表示が出ます。PCの再起動が求められているので、「OK」ボタンを押します。勝手に再起動します。
④PC再起動後デスクトップに下記画面が表示される場合は、ログインしておきましょう。
起動テスト
①Dockerが作動するか確認していきましょう。コマンドプロンプトを起動します。
②"docker --version" で、Dockerのバージョンを確認します。
#docker --version
Docker version 18.06.1-ce, build e68fc7a
③"docker run hello-world"コマンドで「hello-world」イメージからコンテナを起動します。
※「Hello-world」イメージがローカル環境になくても、Docker hubより引っ張ってきてくれます。
#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 image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 4ab4c602aa5e 4 weeks ago 1.84kB
⑤コンテナを一覧表示してみます。
#docker container ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8823b5cc9aa0 hello-world "/hello" 6 hours ago Exited (0) 6 hours ago nervous_mcnulty
コンテナと、イメージの削除
イメージをもとにコンテナが作られるので、コンテナ→イメージから削除していきます。
※逆順だとエラーが出ます。
①コンテナを削除してみます。
コンテナIDは、起動テストの⑤で確認したIDとなります。
#docker rm コンテナID
削除できたか、確認します。何も表示されなければ、削除できています。
#docker container ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
②「Hello-world」イメージを削除してみます。
#docker rmi hello-world
削除できたか、確認します。何も表示されなければ、削除できています。
#docker image ls
おわり
これで、Windows10ProからDockerを触れるようになりました。
次はDockerで開発環境の構築をしていきたいです。
以上