Docker 를 설치하는 몇 가지 방법이 있습니다.
도커를 설치하는 몇 가지 방법이 있습니다. 여기서 살펴볼 설치 방법은 아래와 같습니다.
ㄴ 리포지토리를 이용한 설치
ㄴ Docker CE 를 설치
ㄴ 스크립트를 이용한 설치
1. 리포지토리를 이용한 설치
1-1. apt 패키지 인덱스를 업데이트
1 2 3 4 5 6 7 8 9 10 11 12 | $ sudo apt-get update Hit:1 http://kr.archive.ubuntu.com/ubuntu xenial InRelease Hit:2 http://kr.archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:3 http://kr.archive.ubuntu.com/ubuntu xenial-backports InRelease Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [60.3 kB] Get:6 http://security.ubuntu.com/ubuntu xenial-security/main DEP-11 64x64 Icons [62.6 kB] Get:7 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [49.7 kB] Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe DEP-11 64x64 Icons [80.0 kB] Fetched 355 kB in 4s (73.7 kB/s) Reading package lists... Done | cs |
1-2. apt 가 https 를 통해 저장소를 사용할 수 있도록 패키지들을 설치
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | $ sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common Hit:1 http://kr.archive.ubuntu.com/ubuntu xenial InRelease Hit:2 http://kr.archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:3 http://kr.archive.ubuntu.com/ubuntu xenial-backports InRelease Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB] Fetched 102 kB in 1s (71.6 kB/s) Reading package lists... Done Reading package lists... Done Building dependency tree Reading state information... Done apt-transport-https is already the newest version (1.2.24). ca-certificates is already the newest version (20170717~16.04.1). software-properties-common is already the newest version (0.96.20.7). The following NEW packages will be installed: curl 0 upgraded, 1 newly installed, 0 to remove and 90 not upgraded. Need to get 138 kB of archives. After this operation, 338 kB of additional disk space will be used. Get:1 http://kr.archive.ubuntu.com/ubuntu xenial-updates/main amd64 curl amd64 7.47.0-1ubuntu2.3 [138 kB] Fetched 138 kB in 0s (714 kB/s) Selecting previously unselected package curl. (Reading database ... 212836 files and directories currently installed.) Preparing to unpack .../curl_7.47.0-1ubuntu2.3_amd64.deb ... Unpacking curl (7.47.0-1ubuntu2.3) ... Processing triggers for man-db (2.7.5-1) ... Setting up curl (7.47.0-1ubuntu2.3) ... | cs |
1-3. 도커의 공식적인 GPG key 를 추가
1 2 3 | $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - OK | cs |
1-4. 지문 인식 키의 여부를 확인
1 2 3 | $ sudo apt-key fingerprint 0EBFCD88 | grep docker@docker.com || exit 1 uid Docker Release (CE deb) <docker@docker.com> | cs |
* "9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88" 의 마지막 8자리를 검색하여 지문 인식 키의 여부를 확인합니다.
1-5. 안정적으로 저장소를 구축하기 위한 설정
1 2 | $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | cs |
2. 도커 CE 를 이용한 설치
2-1. 패키지 인덱스를 업데이트
1 2 3 4 5 6 7 8 9 10 | $ sudo apt-get update Hit:1 http://kr.archive.ubuntu.com/ubuntu xenial InRelease Hit:2 http://kr.archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:3 http://kr.archive.ubuntu.com/ubuntu xenial-backports InRelease Get:4 https://download.docker.com/linux/ubuntu xenial InRelease [49.8 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB] Get:6 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages [2,579 B] Fetched 155 kB in 2s (66.9 kB/s) Reading package lists... Done | cs |
2-2. 설치 가능한 도커 버전을 확인
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $ apt-cache madison docker-ce docker-ce | 17.10.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/edge amd64 Packages docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/edge amd64 Packages docker-ce | 17.07.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/edge amd64 Packages docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/edge amd64 Packages docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/edge amd64 Packages docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/edge amd64 Packages docker-ce | 17.05.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/edge amd64 Packages docker-ce | 17.04.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/edge amd64 Packages docker-ce | 17.03.2~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages | cs |
2-3. 가장 최근 버전의 도커 CE 를 설치
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | $ sudo apt-get install -y docker-ce Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: aufs-tools cgroupfs-mount git git-man liberror-perl Suggested packages: git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki git-svn The following NEW packages will be installed: aufs-tools cgroupfs-mount docker-ce git git-man liberror-perl 0 upgraded, 6 newly installed, 0 to remove and 90 not upgraded. Need to get 25.0 MB of archives. After this operation, 126 MB of additional disk space will be used. Get:1 http://kr.archive.ubuntu.com/ubuntu xenial/universe amd64 aufs-tools amd64 1:3.2+20130722-1.1ubuntu1 [92.9 kB] Get:2 http://kr.archive.ubuntu.com/ubuntu xenial/universe amd64 cgroupfs-mount all 1.2 [4,970 B] Get:3 http://kr.archive.ubuntu.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB] Get:4 http://kr.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.3 [736 kB] Get:5 https://download.docker.com/linux/ubuntu xenial/stable amd64 docker-ce amd64 17.09.0~ce-0~ubuntu [21.0 MB] Get:6 http://kr.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.3 [3,102 kB] Fetched 25.0 MB in 3s (7,596 kB/s) Selecting previously unselected package aufs-tools. (Reading database ... 212843 files and directories currently installed.) Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1ubuntu1_amd64.deb ... Unpacking aufs-tools (1:3.2+20130722-1.1ubuntu1) ... Selecting previously unselected package cgroupfs-mount. Preparing to unpack .../cgroupfs-mount_1.2_all.deb ... Unpacking cgroupfs-mount (1.2) ... Selecting previously unselected package docker-ce. Preparing to unpack .../docker-ce_17.09.0~ce-0~ubuntu_amd64.deb ... Unpacking docker-ce (17.09.0~ce-0~ubuntu) ... Selecting previously unselected package liberror-perl. Preparing to unpack .../liberror-perl_0.17-1.2_all.deb ... Unpacking liberror-perl (0.17-1.2) ... Selecting previously unselected package git-man. Preparing to unpack .../git-man_1%3a2.7.4-0ubuntu1.3_all.deb ... Unpacking git-man (1:2.7.4-0ubuntu1.3) ... Selecting previously unselected package git. Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.3_amd64.deb ... Unpacking git (1:2.7.4-0ubuntu1.3) ... Processing triggers for libc-bin (2.23-0ubuntu9) ... Processing triggers for man-db (2.7.5-1) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for systemd (229-4ubuntu19) ... Setting up aufs-tools (1:3.2+20130722-1.1ubuntu1) ... Setting up cgroupfs-mount (1.2) ... Setting up docker-ce (17.09.0~ce-0~ubuntu) ... Setting up liberror-perl (0.17-1.2) ... Setting up git-man (1:2.7.4-0ubuntu1.3) ... Setting up git (1:2.7.4-0ubuntu1.3) ... Processing triggers for libc-bin (2.23-0ubuntu9) ... Processing triggers for systemd (229-4ubuntu19) ... Processing triggers for ureadahead (0.100.0-19) ... | cs |
3. 스크립트를 사용하여 도커를 설치
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | $ curl -fsSL https://get.docker.com/ |sudo sh # Executing docker install script, commit: 490beaa Warning: the "docker" command appears to already exist on this system. If you already have Docker installed, this script can cause trouble, which is why we're displaying this warning and provide the opportunity to cancel the installation. If you installed the current Docker package using this script and are using it again to update Docker, you can safely ignore this message. You may press Ctrl+C now to abort this script. + sleep 20 + sudo -E sh -c apt-get update -qq >/dev/null + sudo -E sh -c apt-get install -y -qq apt-transport-https ca-certificates curl software-properties-common >/dev/null + sudo -E sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null + sudo -E sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge" > /etc/apt/sources.list.d/docker.list + [ ubuntu = debian ] + sudo -E sh -c apt-get update -qq >/dev/null + sudo -E sh -c apt-get install -y -qq docker-ce >/dev/null + sudo -E sh -c docker version Client: Version: 17.10.0-ce API version: 1.33 Go version: go1.8.3 Git commit: f4ffd25 Built: Tue Oct 17 19:04:16 2017 OS/Arch: linux/amd64 Server: Version: 17.10.0-ce API version: 1.33 (minimum version 1.12) Go version: go1.8.3 Git commit: f4ffd25 Built: Tue Oct 17 19:02:56 2017 OS/Arch: linux/amd64 Experimental: false If you would like to use Docker as a non-root user, you should now consider adding your user to the "docker" group with something like: sudo usermod -aG docker user Remember that you will have to log out and back in for this to take effect! WARNING: Adding a user to the "docker" group will grant the ability to run containers which can be used to obtain root privileges on the docker host. Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface for more information. | cs |
4. 도커 설치 후 확인
4-1. 도커 버전을 출력
1 2 3 | $ docker -v Docker version 17.10.0-ce, build f4ffd25 | cs |
4-2. hello-world 를 실행
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | $ sudo docker run --rm hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 5b0f327be733: Pull complete Digest: sha256:07d5f7800dfe37b8c2196c7b1c524c33808ce2e0f74e7aa00e603295ca9a0972 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 ID: https://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/ | cs |
* 위의 --rm 옵션은 컨테이너 안의 프로세스가 종료되면 컨테이너를 자동으로 삭제합니다.
* 도커를 실행하기 위해선 루트에 해당하는 권한이 필요하기 때문에 앞에 sudo 를 붙여 실행합니다.
5. 루트가 아닌 사용자로서 도커를 관리할 계정과 그룹을 생성
5-1. 도커 그룹을 생성
1 2 | $ sudo groupadd docker | cs |
* 도커 그룹을 추가합니다.
5-2. 도커 그룹에 속할 유저를 추가
1 2 | $ sudo usermod -aG docker $USER | cs |
* 현재 접속 중인 사용자 혹은 도커를 관리할 사용자에게 권한을 부여합니다.
* 사용자가 접속해 있는 상태라면 재접속 후에 권한이 적용됩니다.
5-3. 도커 서비스를 재시작
1 2 | $ sudo service docker restart | cs |
6. sudo 를 사용하지 않고 도커 명령어를 실행
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | $ docker run --rm hello-world 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 ID: https://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/ | cs |
'Operating System > Linux' 카테고리의 다른 글
ubuntu 버전 확인 (0) | 2017.10.19 |
---|---|
ubuntu group (0) | 2017.10.19 |
Ubuntu Desktop 설치 (0) | 2017.10.18 |
Ubuntu ssh server 설치 (0) | 2017.10.18 |
head 명령어 (0) | 2017.10.16 |