34. 取得 base image
> docker pull dockerfile/ubuntu
OS
User Space
Kernel Space
Process
Image
Ubuntu 14.04
35. 啟動 container
> docker run -i -t dockerfile/ubuntu bash
root@ce9fd02cffaf:/#
OS
User Space
Kernel Space
Process
User Space
Process
Container
ce8fd02cffaf
Image
Ubuntu 14.04
37. List and Commit container
OS
Image
Ubuntu 14.04
User Space
Kernel Space
Process
Image
koji/java8
> docker ps -a
CONTAINER ID IMAGE COMMAND
ce9fd02cffaf dockerfile/ubuntu:latest bash
> docker commit ce9fd02cffaf koji/java8
38. Push image to docker hub
OS
Image
Ubuntu 14.04
User Space
Kernel Space
Process
Image
koji/java8
> docker push koji/java8
40. 啟動新 image 上的 container
OS
Image
Ubuntu 14.04
User Space
Kernel Space
Process
User Space
Process
Image
koji/java8
Container
63d304af38e
> docker run -i -t koji/java8 bash
root@63d304af38ee:/#
41. 安裝 Tomcat 7
OS
Image
Ubuntu 14.04
User Space
Kernel Space
Process
User Space
Process
Image
koji/java8
root@63d304af38ee:/# apt-get install tomcat7
Container
63d304af38e
42. Commit container
OS
Image
Ubuntu 14.04
User Space
Kernel Space
Process
Image
koji/java8
root@63d304af38ee:/# exit
> docker commit 63d304af38ee koji/java8-tomcat7
Image
koji/java8-tomcat7
46. •除了上述手動方式建立 image 之外,我們也
可以透過敘述指令的 案來建立
•Docker can act as a builder and read
instructions from a text Dockerfile to
automate the steps you would
otherwise take manually to create an
image
Dockerfile
47. Dockerfile (cont.)
> docker build .
FROM ubuntu↵
MAINTAINER Koji lin <koji.lin@gmail.com>↵
!
RUN echo "deb http://archive.ubuntu.com/
ubuntu precise main universe" > /etc/apt/
sources.list↵
RUN apt-get update↵
!
RUN apt-get install -y inotify-tools nginx
apache2 openssh-server↵