docker 설치 및 정보 확인.

2017. 9. 11. 16:02리눅스/우분투( Ubuntu)

<테스트 환경>

 - OS : Ubuntu 16.04.2

 - 인터넷 : 사용 가능

 - 최소 조건 : kernel 버전이 3.10 이상이여야 한다. ( centos7 , ubuntu 16.04 이상 )

#1. Docker 설치

 

root@host01:~#  apt-get update                                             --> 설치 전 ubuntu package 업데이트.

                                                                                        --> Done 으로 종료되면 상관이 없다. Error 발생시 rebooting 후 재시도.

root@host01:~# apt-get update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://ftp.daumkakao.com/ubuntu xenial InRelease
Hit:3 http://ftp.daumkakao.com/ubuntu xenial-updates InRelease
Hit:4 http://ftp.daumkakao.com/ubuntu xenial-backports InRelease
Fetched 102 kB in 1s (63.6 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
47 packages can be upgraded. Run 'apt list --upgradable' to see them.

root@host01:~# curl -sSL https://get.docker.com/ | sh                  --> 도커 홈페이지에서 최신 버전을 다운받아 설치하게 된다.

root@host01:~# systemctl enable docker                                   --> 부팅 시 자동시작 등록
root@host01:~# systemctl start docker                                      --> docker 서비스 시작

root@host01:~# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since 월 2017-09-11 14:58:07 KST; 50min ago
     Docs: https://docs.docker.com
 Main PID: 24912 (dockerd)
   CGroup: /system.slice/docker.service
           ├─24912 /usr/bin/dockerd -H fd://
           └─24917 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libc

 9월 11 14:58:05 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:05.813799896+09:00" level=warning msg="Your kernel does not support swap memory limit"
 9월 11 14:58:05 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:05.814372300+09:00" level=warning msg="Your kernel does not support cgroup rt period"
 9월 11 14:58:05 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:05.814822650+09:00" level=warning msg="Your kernel does not support cgroup rt runtime"
 9월 11 14:58:05 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:05.816344139+09:00" level=info msg="Loading containers: start."
 9월 11 14:58:06 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:06.993918711+09:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.
 9월 11 14:58:07 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:07.229739411+09:00" level=info msg="Loading containers: done."
 9월 11 14:58:07 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:07.308734925+09:00" level=info msg="Docker daemon" commit=8784753 graphdriver(s)=aufs version=17
 9월 11 14:58:07 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:07.309252344+09:00" level=info msg="Daemon has completed initialization"
 9월 11 14:58:07 host01.cloud.com systemd[1]: Started Docker Application Container Engine.
 9월 11 14:58:07 host01.cloud.com dockerd[24912]: time="2017-09-11T14:58:07.469656176+09:00" level=info msg="API listen on /var/run/docker.sock"

 #2. Docker 버전 / 정보 확인

 

 root@host01:~# docker version                                                  --> 도커를 설치하면 client/server 가 동시에 설치 된다.
Client:
 Version:      17.07.0-ce
 API version:  1.31
 Go version:   go1.8.3
 Git commit:   8784753
 Built:        Tue Aug 29 17:42:53 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.07.0-ce
 API version:  1.31 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   8784753
 Built:        Tue Aug 29 17:41:43 2017
 OS/Arch:      linux/amd64
 Experimental: false

root@host01:~# docker info                                                        --> 도커 구성 정보를 볼 수 있다.
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.07.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 3addd840653146c90a254301d6c3a663c7fd6429
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-81-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 3.859GiB
Name: host01.cloud.com
ID: E5VS:S66K:IGMQ:PH7L:UNLN:PTR7:MLVW:VING:6YIT:NAK2:TVGP:AUDV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

 

#3. Docker 설치시 네트워크가 생성된다.

 --> 많은 역할을 하게 된다.

 root@host01:~# ifconfig
docker0   Link encap:Ethernet  HWaddr 02:42:ca:2b:d4:43
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

 

#4. Docker 설치 위치

 - 모든 데이터가 저장되는 곳. (그렇기에 docker 를 삭제해도 해당 폴더는 삭제되지 않는다.)

 root@host01:~# ls -rlt /var/lib/docker/
total 40
drwx------ 2 root root 4096  9ì›” 11 14:58 containers
drwx------ 4 root root 4096  9ì›” 11 14:58 plugins
drwx------ 5 root root 4096  9ì›” 11 14:58 aufs
drwx------ 3 root root 4096  9ì›” 11 14:58 image
drwx------ 2 root root 4096  9ì›” 11 14:58 volumes
drwx------ 2 root root 4096  9ì›” 11 14:58 trust
drwxr-x--- 3 root root 4096  9ì›” 11 14:58 network
drwx------ 2 root root 4096  9ì›” 11 14:58 tmp
drwx------ 2 root root 4096  9ì›” 11 14:58 swarm
drwx------ 2 root root 4096  9ì›” 11 14:58 builder

 

#5. 일반 계정이 docker 실행을 하기 위해서는 권한을 가져야 한다.

 - 권한을 갖고 있지 않으면 아래와 같은 에러가 발생한다.

 guru@host01:~$ docker run ubuntu -it /bin/bash
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.31/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

 

root@host01:~# useradd guru -m -s /bin/bash
root@host01:~# ls -rlt /home/
total 8
drwxr-xr-x 17 hp   hp   4096  6ì›” 25 08:50 hp
drwxr-xr-x  2 guru guru 4096  9ì›” 11 15:29 guru
root@host01:~#
root@host01:~#
root@host01:~#
root@host01:~# passwd guru

root@host01:~# ls -rlt /var/run/docker.sock
srw-rw---- 1 root docker 0  9ì›” 11 14:58 /var/run/docker.sock
root@host01:~# id guru
uid=1001(guru) gid=1001(guru) groups=1001(guru)
root@host01:~#
root@host01:~#
root@host01:~#
root@host01:~# usermod -aG docker guru
root@host01:~# id guru
uid=1001(guru) gid=1001(guru) groups=1001(guru),999(docker)
root@host01:~#