SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
Docker란 무엇인가? : Docker 기본 사용법 
이재홍 
http://pyrasis.com 
Docker Seoul Meetup #1 / August 23, 2014
기존의 서버 구축 
OS 설치 
웹 서버 설치 및 설정 
DB 설치 및 설정 
소스 복사 
사람이 일일이 설정
Immutable Infrastructure 
호스트OS와 서비스 운영 환경 분리 
한 번 설정한 운영 환경은 변경하지 않는다(Immutable). 
서비스 운영 환경을 통째로 교체한다. 
마치 클라우드 플랫폼처럼...
Virtual Machine 
vs. 
Docker
Virtual Machine 
http://www.docker.com/whatisdocker/
Docker 
http://www.docker.com/whatisdocker/
Ubuntu 14.04, Docker 1.1.2
Linux Container
Docker 
= 
cgroups, namespaces... 
+ 
Docker Hub 
+ 
α
Docker 이미지와 
컨테이너
http://www.slideshare.net/dotCloud/why-docker
Docker 이미지 
실행 파일, 라이브러리, 소스 등을 묶은 이미지 파일 
예) OS의 실행 파일 
Docker 컨테이너 
이미지를 실행한 상태 
예) OS의 프로세스
설치 
$ sudo wget -qO- https://get.docker.io/ | sh
Ubuntu 
$ sudo apt-get update 
$ sudo apt-get install docker.io 
$ sudo ln -sf  
/usr/bin/docker.io /usr/local/bin/docker
CentOS 
CentOS 6.5 
$ sudo yum install  
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm 
$ sudo yum install docker-io 
CentOS 7 
$ sudo yum install docker
Mac OS X 
https://github.com/boot2docker/osx-installer/releases 
Windows 
https://github.com/boot2docker/windows-installer/releases
Mac OS X와 Windows용 
Docker는 
Boot2Docker 
VirtualBox가 내장 
가상 머신으로 리눅스를 실행한 것
기본 실습
매번 sudo를 붙이지 않으려면... 
$ sudo groupadd docker 
$ sudo gpasswd -a ${USER} docker 
$ sudo service docker restart
이미지 검색 
$ docker search ubuntu 
이미지 받기 
$ docker pull ubuntu:latest 
이미지 목록 출력하기 
$ docker images
컨테이너 생성하기 
$ docker run -i -t --name hello  
ubuntu /bin/bash 
컨테이너 목록 확인하기 
$ docker ps -a 
컨테이너 시작하기 
$ docker start hello
컨테이너 재시작하기 
$ docker restart hello 
컨테이너에 접속하기 
$ docker attach hello 
컨테이너 정지하기 
$ docker stop hello
컨테이너 삭제하기 
$ docker rm hello 
이미지 삭제하기 
$ docker rmi ubuntu:latest 
모든 컨테이너 삭제하기 
$ docker rm `docker ps -aq`
이미지 생성하기
FROM ubuntu:14.04 
MAINTAINER Foo Bar <foo@bar.com> 
RUN apt-get update 
RUN apt-get install -y nginx 
RUN echo "ndaemon off;" >> /etc/nginx/nginx.conf 
RUN chown -R www-data:www-data /var/lib/nginx 
VOLUME ["/data", "/etc/nginx/site-enabled", "/var/log/nginx"] 
WORKDIR /etc/nginx 
CMD ["nginx"] 
EXPOSE 80 
EXPOSE 443 
Dockerfile
FROM: 어떤 이미지를 기반으로 할지 설정 
MAINTAINER: 이미지 작성자 정보 
RUN: 이미지에서 스크립트나 명령 실행 
CMD: 컨테이너가 시작되었을 때 스크립트나 명령 실행 
ENTRYPOINT: 컨테이너가 시작되었을 때 스크립트나 명령 
실행(docker run에서 처리 방식이 다름) 
EXPOSE: 호스트와 연결할 포트 번호 설정 
ENV: 환경 변수 설정 
ADD, COPY: 이미지에 파일 추가 
VOLUME: 데이터를 호스트에 저장하도록 설정 
USER: 명령을 실행할 사용자 계정 설정 
WORKDIR: 명령을 실행할 디렉터리 설정 
ONBUILD: FROM으로 이미지가 사용될 때 실행할 명령 설정
이미지 생성하기 
$ docker build --tag hello:0.1 . 
컨테이너 생성하기 
$ docker run --name hello-nginx -d -p 80:80  
-v /root/data:/data hello:0.1
기타 명령
이미지 히스토리 살펴보기 
$ docker history hello:0.1 
컨테이너에서 파일 꺼내기 
$ docker cp  
hello-nginx:/etc/nginx/nginx.conf ./ 
컨테이너의 변경 사항을 이미지로 저장하기 
$ docker commit -a "Foo Bar <foo@bar.com>"  
-m "add hello.txt" hello-nginx hello:0.2
컨테이너에서 변경된 파일 확인하기 
$ docker diff hello-nginx 
이미지와 컨테이너의 세부정보 확인하기 
$ docker inspect hello-nginx
참고 문서 
http://pyrasis.com/Docker/Docker-HOWTO
"가장 빨리 만나는 Docker" 출간 및 원고 공개 
http://www.pyrasis.com/private/2014/11/30/publish-docker-for-the-really-impatient-book
"아마존 웹 서비스를 다루는 기술" 출간 및 원고 공개 
http://www.pyrasis.com/private/2014/09/30/publish-the-art-of-amazon-web-services-book

Contenu connexe

Tendances

Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionPeng Xiao
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginnersJuneyoung Oh
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기raccoony
 
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Edureka!
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...Simplilearn
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to DockerAditya Konarde
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)Gourav Varma
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Herofazalraja
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An IntroductionPOSSCON
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefitsAmit Manwade
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...Edureka!
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionSparkbit
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with DockerRavindu Fernando
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker, Inc.
 
Docker intro
Docker introDocker intro
Docker introOleg Z
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 

Tendances (20)

Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginners
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기
 
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
 
Docker in real life
Docker in real lifeDocker in real life
Docker in real life
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
[9월 런치 세미나] 도커와 쿠버네티스 기술에 스며들다
[9월 런치 세미나] 도커와 쿠버네티스 기술에 스며들다[9월 런치 세미나] 도커와 쿠버네티스 기술에 스며들다
[9월 런치 세미나] 도커와 쿠버네티스 기술에 스며들다
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An Introduction
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016
 
Docker intro
Docker introDocker intro
Docker intro
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 

En vedette

Docker로 서버 개발 편하게 하기
Docker로 서버 개발 편하게 하기Docker로 서버 개발 편하게 하기
Docker로 서버 개발 편하게 하기Dronix
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of EverythingMichael Ducy
 
1711 azure-live
1711 azure-live1711 azure-live
1711 azure-live세준 김
 
Foreman in Your Data Center :OSDC 2015
Foreman in Your Data Center :OSDC 2015Foreman in Your Data Center :OSDC 2015
Foreman in Your Data Center :OSDC 2015Stephen Benjamin
 
Foreman in your datacenter
Foreman in your datacenterForeman in your datacenter
Foreman in your datacenterlzap
 
Selenium을 이용한 동적 사이트 크롤러 만들기
Selenium을 이용한 동적 사이트 크롤러 만들기Selenium을 이용한 동적 사이트 크롤러 만들기
Selenium을 이용한 동적 사이트 크롤러 만들기Gyuhyeon Jeon
 
141118 최창원 웹크롤러제작
141118 최창원 웹크롤러제작141118 최창원 웹크롤러제작
141118 최창원 웹크롤러제작Changwon Choe
 

En vedette (7)

Docker로 서버 개발 편하게 하기
Docker로 서버 개발 편하게 하기Docker로 서버 개발 편하게 하기
Docker로 서버 개발 편하게 하기
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of Everything
 
1711 azure-live
1711 azure-live1711 azure-live
1711 azure-live
 
Foreman in Your Data Center :OSDC 2015
Foreman in Your Data Center :OSDC 2015Foreman in Your Data Center :OSDC 2015
Foreman in Your Data Center :OSDC 2015
 
Foreman in your datacenter
Foreman in your datacenterForeman in your datacenter
Foreman in your datacenter
 
Selenium을 이용한 동적 사이트 크롤러 만들기
Selenium을 이용한 동적 사이트 크롤러 만들기Selenium을 이용한 동적 사이트 크롤러 만들기
Selenium을 이용한 동적 사이트 크롤러 만들기
 
141118 최창원 웹크롤러제작
141118 최창원 웹크롤러제작141118 최창원 웹크롤러제작
141118 최창원 웹크롤러제작
 

Similaire à Docker란 무엇인가? : Docker 기본 사용법

[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)Ji-Woong Choi
 
Introduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTIntroduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTHosang Jeon
 
[오픈소스컨설팅]Docker on Kubernetes v1
[오픈소스컨설팅]Docker on Kubernetes v1[오픈소스컨설팅]Docker on Kubernetes v1
[오픈소스컨설팅]Docker on Kubernetes v1Ji-Woong Choi
 
Introduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTIntroduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTLOGISPOT
 
docker_quick_start
docker_quick_startdocker_quick_start
docker_quick_startSukjin Yun
 
Docker 사용가이드 public v0.1
Docker 사용가이드 public v0.1Docker 사용가이드 public v0.1
Docker 사용가이드 public v0.1Steve Shim
 
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)CONNECT FOUNDATION
 
aws/docker/rails를 활용한 시스템 구축/운용 - docker편
aws/docker/rails를 활용한 시스템 구축/운용 - docker편aws/docker/rails를 활용한 시스템 구축/운용 - docker편
aws/docker/rails를 활용한 시스템 구축/운용 - docker편negabaro
 
[17.01.19] docker introduction (Korean Version)
[17.01.19] docker introduction (Korean Version)[17.01.19] docker introduction (Korean Version)
[17.01.19] docker introduction (Korean Version)Ildoo Kim
 
Docker 기반 개발환경 구축 - XE Open seminar #2
Docker 기반 개발환경 구축 - XE Open seminar #2Docker 기반 개발환경 구축 - XE Open seminar #2
Docker 기반 개발환경 구축 - XE Open seminar #2XpressEngine
 
[1A6]Docker로 보는 서버 운영의 미래
[1A6]Docker로 보는 서버 운영의 미래[1A6]Docker로 보는 서버 운영의 미래
[1A6]Docker로 보는 서버 운영의 미래NAVER D2
 
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXpressEngine
 
docker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea Clouddocker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea CloudJude Kim
 
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container DayAmazon Web Services Korea
 
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]David Lee
 
Jupyter notebok tensorboard 실행하기_20160706
Jupyter notebok tensorboard 실행하기_20160706Jupyter notebok tensorboard 실행하기_20160706
Jupyter notebok tensorboard 실행하기_20160706Yong Joon Moon
 
Dockerfile과 Bash
Dockerfile과 BashDockerfile과 Bash
Dockerfile과 Bashpyrasis
 

Similaire à Docker란 무엇인가? : Docker 기본 사용법 (20)

[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
 
Introduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTIntroduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOT
 
[오픈소스컨설팅]Docker on Kubernetes v1
[오픈소스컨설팅]Docker on Kubernetes v1[오픈소스컨설팅]Docker on Kubernetes v1
[오픈소스컨설팅]Docker on Kubernetes v1
 
Introduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTIntroduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOT
 
docker_quick_start
docker_quick_startdocker_quick_start
docker_quick_start
 
Docker 사용가이드 public v0.1
Docker 사용가이드 public v0.1Docker 사용가이드 public v0.1
Docker 사용가이드 public v0.1
 
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
 
Docker
DockerDocker
Docker
 
aws/docker/rails를 활용한 시스템 구축/운용 - docker편
aws/docker/rails를 활용한 시스템 구축/운용 - docker편aws/docker/rails를 활용한 시스템 구축/운용 - docker편
aws/docker/rails를 활용한 시스템 구축/운용 - docker편
 
[17.01.19] docker introduction (Korean Version)
[17.01.19] docker introduction (Korean Version)[17.01.19] docker introduction (Korean Version)
[17.01.19] docker introduction (Korean Version)
 
Docker 기반 개발환경 구축 - XE Open seminar #2
Docker 기반 개발환경 구축 - XE Open seminar #2Docker 기반 개발환경 구축 - XE Open seminar #2
Docker 기반 개발환경 구축 - XE Open seminar #2
 
[1A6]Docker로 보는 서버 운영의 미래
[1A6]Docker로 보는 서버 운영의 미래[1A6]Docker로 보는 서버 운영의 미래
[1A6]Docker로 보는 서버 운영의 미래
 
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
 
Docker osc 0508
Docker osc 0508Docker osc 0508
Docker osc 0508
 
docker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea Clouddocker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
 
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
 
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
 
Jupyter notebok tensorboard 실행하기_20160706
Jupyter notebok tensorboard 실행하기_20160706Jupyter notebok tensorboard 실행하기_20160706
Jupyter notebok tensorboard 실행하기_20160706
 
Dockerfile과 Bash
Dockerfile과 BashDockerfile과 Bash
Dockerfile과 Bash
 
K8s in action02
K8s in action02K8s in action02
K8s in action02
 

Docker란 무엇인가? : Docker 기본 사용법

  • 1. Docker란 무엇인가? : Docker 기본 사용법 이재홍 http://pyrasis.com Docker Seoul Meetup #1 / August 23, 2014
  • 2. 기존의 서버 구축 OS 설치 웹 서버 설치 및 설정 DB 설치 및 설정 소스 복사 사람이 일일이 설정
  • 3. Immutable Infrastructure 호스트OS와 서비스 운영 환경 분리 한 번 설정한 운영 환경은 변경하지 않는다(Immutable). 서비스 운영 환경을 통째로 교체한다. 마치 클라우드 플랫폼처럼...
  • 4.
  • 5.
  • 6.
  • 12.
  • 13. Docker = cgroups, namespaces... + Docker Hub + α
  • 16.
  • 17. Docker 이미지 실행 파일, 라이브러리, 소스 등을 묶은 이미지 파일 예) OS의 실행 파일 Docker 컨테이너 이미지를 실행한 상태 예) OS의 프로세스
  • 18. 설치 $ sudo wget -qO- https://get.docker.io/ | sh
  • 19. Ubuntu $ sudo apt-get update $ sudo apt-get install docker.io $ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
  • 20. CentOS CentOS 6.5 $ sudo yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm $ sudo yum install docker-io CentOS 7 $ sudo yum install docker
  • 21. Mac OS X https://github.com/boot2docker/osx-installer/releases Windows https://github.com/boot2docker/windows-installer/releases
  • 22. Mac OS X와 Windows용 Docker는 Boot2Docker VirtualBox가 내장 가상 머신으로 리눅스를 실행한 것
  • 24. 매번 sudo를 붙이지 않으려면... $ sudo groupadd docker $ sudo gpasswd -a ${USER} docker $ sudo service docker restart
  • 25. 이미지 검색 $ docker search ubuntu 이미지 받기 $ docker pull ubuntu:latest 이미지 목록 출력하기 $ docker images
  • 26. 컨테이너 생성하기 $ docker run -i -t --name hello ubuntu /bin/bash 컨테이너 목록 확인하기 $ docker ps -a 컨테이너 시작하기 $ docker start hello
  • 27. 컨테이너 재시작하기 $ docker restart hello 컨테이너에 접속하기 $ docker attach hello 컨테이너 정지하기 $ docker stop hello
  • 28. 컨테이너 삭제하기 $ docker rm hello 이미지 삭제하기 $ docker rmi ubuntu:latest 모든 컨테이너 삭제하기 $ docker rm `docker ps -aq`
  • 30. FROM ubuntu:14.04 MAINTAINER Foo Bar <foo@bar.com> RUN apt-get update RUN apt-get install -y nginx RUN echo "ndaemon off;" >> /etc/nginx/nginx.conf RUN chown -R www-data:www-data /var/lib/nginx VOLUME ["/data", "/etc/nginx/site-enabled", "/var/log/nginx"] WORKDIR /etc/nginx CMD ["nginx"] EXPOSE 80 EXPOSE 443 Dockerfile
  • 31. FROM: 어떤 이미지를 기반으로 할지 설정 MAINTAINER: 이미지 작성자 정보 RUN: 이미지에서 스크립트나 명령 실행 CMD: 컨테이너가 시작되었을 때 스크립트나 명령 실행 ENTRYPOINT: 컨테이너가 시작되었을 때 스크립트나 명령 실행(docker run에서 처리 방식이 다름) EXPOSE: 호스트와 연결할 포트 번호 설정 ENV: 환경 변수 설정 ADD, COPY: 이미지에 파일 추가 VOLUME: 데이터를 호스트에 저장하도록 설정 USER: 명령을 실행할 사용자 계정 설정 WORKDIR: 명령을 실행할 디렉터리 설정 ONBUILD: FROM으로 이미지가 사용될 때 실행할 명령 설정
  • 32. 이미지 생성하기 $ docker build --tag hello:0.1 . 컨테이너 생성하기 $ docker run --name hello-nginx -d -p 80:80 -v /root/data:/data hello:0.1
  • 34. 이미지 히스토리 살펴보기 $ docker history hello:0.1 컨테이너에서 파일 꺼내기 $ docker cp hello-nginx:/etc/nginx/nginx.conf ./ 컨테이너의 변경 사항을 이미지로 저장하기 $ docker commit -a "Foo Bar <foo@bar.com>" -m "add hello.txt" hello-nginx hello:0.2
  • 35. 컨테이너에서 변경된 파일 확인하기 $ docker diff hello-nginx 이미지와 컨테이너의 세부정보 확인하기 $ docker inspect hello-nginx
  • 37. "가장 빨리 만나는 Docker" 출간 및 원고 공개 http://www.pyrasis.com/private/2014/11/30/publish-docker-for-the-really-impatient-book
  • 38. "아마존 웹 서비스를 다루는 기술" 출간 및 원고 공개 http://www.pyrasis.com/private/2014/09/30/publish-the-art-of-amazon-web-services-book