この記事内容は公式の
ままなので、英語が読める人は公式のドキュメントに従いましょう。
Dockerのインストール
元々のyum repoは古いので、Dockerのyum repoを追加する
# 一度yumの更新 $ sudo yum update # docker.repoの追加 $ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF # docker-engineのインストール $ sudo yum install docker-engine # dockerの起動 $ sudo service docker start # テスト起動 $ sudo docker run hello-world sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from hello-world d59cd4c39e50: Pull complete f1d956dc5945: Pull complete Digest: sha256:4f32210e234b4ad5cac92efacc0a3d602b02476c754f13d517e1ada048e5a8ba 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: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
OK.
docker
グループを作る
DockerデーモンはTCPポート代替として機能するUnixソケットに紐付いており、そのUnixソケットはデフォルトでrootがオーナーになっている為、Dockerはrootかsudoでしか動作しない。
ということで、docker
グループを作ってそこにユーザを追加する。
この docker
グループはDockerに於いてrootユーザ同等の権限を持つ。
Docker Daemon Attack Surface と呼ばれるセキュリティ上の影響を考慮する必要がある。
Docker security | Docker Documentation
# dockerグループの作成 $ sudo groupadd docker # dockerグループにuserを追加する $ sudo usermod -aG docker your_username
一度ログアウトし、先述のyour_usernameでログインする。
念の為、sudoなしで起動できることを確認する。
$ docker run hello-world
起動時にdocker daemonを自動起動する
いつもの
$ sudo chkconfig docker on
Dockerのアンインストール
# インストールしているyumパッケージの確認 $ yum list installed | grep docker docker-engine.x86_64 1.7.1-1.el6 @dockerrepo # 該当パッケージを削除 $ sudo yum remove docker-engine.x86_64 # イメージとコンテナとボリュームの削除 $ rm -rf /var/lib/docker