Docker Engine
今更ながら,Dockerを触ってみた.
なぜDockerなのか
一言で言うと,CI/CD (継続的インテグ/継続的ディリバリ)が簡単になるため.
Getting Started
やっぱり本家のGetting Startedをやるのが,基本を理解するのに一番わかり易い.
ここでやるのは,Machine, Swarm, Composeではない,Engineのみ.
Getting Startedをやる.
Installation
$ curl -fsSL https://get.docker.com/ | sh
- in case of over-proxy
$ curl -fsSL https://get.docker.com/gpg | sudo apt-key add -
userをdokcer groupに登録して,デーモン登録してから
$ sudo usermod -aG docker $USER $ sudo sysv-rc-conf --level 456 docker on
logout or reboot
Run whalesay image
$ docker run docker/whalesay cowsay boo $ docker run docker/whalesay cowsay boo-boo $ docker run docker/whalesay ls / $ docker run docker/whalesay ls
Build your own image
以下の手順で作る
1. create directory
2. create/write Dockerfile in the diretory
3. build image from the Dockerfile
- (push the image to DockerHub)
- (run the image as a container)
Dockerfile
FROM docker/whalesay:latest # ベースとなるimage RUN apt-get -y update && apt-get install -y fortunes # commitされるコマンド CMD /usr/games/fortune -a | cowsay # default action, 1つだけ,複数あると最後のみ有効
を作って
docker build -t docker-whale ${Created Directory}
でimageができる.
確認
docker images
Create Docker Hub account & repository
dokcer hubにアクセスして作成すればいい.
Tag and Push your image
docker-whaleという名前のレポジトリができているので,namspace = docker hub accountをつける
docoker tag ${image id} ${namespace}/docker-whale:latest
pushする
$ dokcer login --username=${your account} $ docker push ${your account}/docker-whale:latest
pullする前に,rmi
$ docker rmi docker-whale ${your account}/docker-whale
pullする
$ docker pull ${your account}/docker-whale
確認
$ dokcer images
基本の理解を深める
Docker ハンズオンをみて,一部やってみるのがいい.
所感
git likeに使えていい.Dockerfileはgitで管理すればいいし,imageはDokcer Hubで管理すればいい.LXCよりは断然dokcerだと感じた.
あとは,公式Referenceを見ながらやるのがいいと思う.
ちょっと古いが,知らぬはエンジニアの恥。今さら聞けない【コンテナ/仮想化技術】11選に,この手の技術の表面的な説明が網羅されているので,参考になる.
用語
参考
- https://docs.docker.com/linux
- http://www.slideshare.net/zembutsu/introduction-to-docker-management-and-operations-basic
- http://qiita.com/kiida/items/059e34ea53c16e6bc9ec
- https://docs.docker.com/
- https://docs.docker.com/engine/reference/
- http://qiita.com/hihihiroro/items/6dda871dc2566801a6da
- http://paiza.hatenablog.com/entry/2014/10/21/%E7%9F%A5%E3%82%89%E3%81%AC%E3%81%AF%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%8B%E3%82%A2%E3%81%AE%E6%81%A5%E3%80%82%E4%BB%8A%E3%81%95%E3%82%89%E8%81%9E%E3%81%91%E3%81%AA%E3%81%84%E3%80%90%E3%82%B3%E3%83%B3