プログラミングとかLinuxとかの備忘録

プログラミング、Linuxでハマった箇所や環境構築のメモ

Ubuntu15.10でdockerを動かす

スポンサーリンク

インストール

$ sudo apt-get -y install docker.io

ユーザ設定

dockerグループではないユーザでは以下のようなエラーが出る

$ docker images
FATA[0000] Get http://%2Fvar%2Frun%2Fdocker.sock/v1.18/images/json: dial unix /var/run/docker.sock: connect: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?

sudoするかdockerを使用するユーザをdockerグループに追加すればいいので
dockerグループに追加する

$ sudo groupadd docker
$ sudo gpasswd -a ${USER} docker
$ sudo systemctl restart docker

$ sudo reboot

dockerを試す

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

$ docker pull centos
latest: Pulling from centos
47d44cb6f252: Pull complete 
838c1c5c4f83: Pull complete 
5764f0a31317: Pull complete 
60e65a8e4030: Pull complete 
centos:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:8072bc7c66c3d5b633c3fddfc2bf12d5b4c2623f7004d9eed6aae70e0e99fbd7
Status: Downloaded newer image for centos:latest

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos              latest              60e65a8e4030        2 weeks ago         196.6 MB

イメージが準備出来たので コンテナを起動

$ docker run -it centos:latest
[root@a7c6fef2e476 /]# whoami
root
[root@a7c6fef2e476 /]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
[root@a7c6fef2e476 /]# exit