SlideShare ist ein Scribd-Unternehmen logo
1 von 84
Downloaden Sie, um offline zu lesen
1
2
跨領域
正夯
深藏
若虛
死會
證明
NCHU
EECSeC


















Now
9
11
13
$  wget  -­‐qO-­‐  https://get.docker.com/  |  sh
Kitematic
18
$  [sudo]  docker  [command]  [flags]  [arguments]
$ docker
Commands:
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
$  docker
$ docker version
Client version: 1.62
Client API version: 1.18
Go version (client): go1.4.1
Git commit (client): a8a31ef
OS/Arch (client): darwin/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 4749651
$  docker  version
$ docker info
Containers: 3
Images: 65
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
…
Execution Driver: native-0.2
Kernel Version: 4.0.3-boot2docker
Operating System: Boot2Docker 1.6.2 (TCL 5.4); ……
$  docker  info
$ docker run --help
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container
……
$  docker  command  -­‐-­‐help
$  docker  run  image  execute  [argument,  …]
$ docker run ubuntu:14.04 /bin/echo 'Hello world'
Hello world
$  docker  run  image  execute  [argument,  …]
$ docker run -it ubuntu:14.04 /bin/bash
root@af8bae53bdd3:/#
$  docker  run  -­‐it  image  execute  [argument,  …]
$ docker run -d ubuntu:14.04 /bin/echo  

-c "while true; do echo hello world; sleep 1; done"
1e5535038e285177d5214659a068137486f96ee5c2e85a4ac52dc83f2ebe4147
$  docker  run  -­‐d  image  execute  [argument,  …]
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
1e5535038e28 ubuntu:14.04 /bin/sh… 2 minutes ago Up 1 minute insane_babbage
$  docker  ps
$ docker logs 1e5535038e28
hello world
hello world
hello world
$  docker  logs  [container  ID/Name]
$ docker logs insane_babbage
hello world
hello world
hello world
$  docker  logs  [container  ID/Name]
$  docker  run  -­‐P|-­‐p  …
$ docker run -d -P nginx:latest
Unable to find image 'nginx:latest' locally
latest: Pulling from nginx
39bb80489af7: Pull complete
……
72d73c46937a: Pull complete
Status: Downloaded newer image for nginx:latest
23e601370946fc9fbdfd6204e1bf70e88e6c18078a0c6ee8640acd2e6694b645
$  docker  run  -­‐d  -­‐P  image  execute  [argument,  …]
$ docker ps
CONTAINER ID IMAGE COMMAND STATUS PORTS
23e601370946 nginx:latest "nginx … Up 1 minute 0.0.0.0:32768->443/tcp

0.0.0.0:32769->80/tcp
$  docker  ps
$ boot2socker ip
192.168.59.103
$  boot2ocker  ip
$ docker run -d -p 80 nginx:latest
40dd6835e35843fdc1853e92b9922f6406f874793c085e1f71cb3967e1157cf3
$  docker  run  -­‐d  -­‐p  container_port  …
$ docker ps
CONTAINER ID IMAGE COMMAND STATUS PORTS
40dd6835e358 nginx:latest "nginx … Up 1 minute 443/tcp

0.0.0.0:32770->80/tcp
$  docker  ps
$ docker run -d -p 10080:80 nginx:latest
40dd6835e35843fdc1853e92b9922f6406f874793c085e1f71cb3967e1157cf3
$  docker  run  -­‐d  -­‐p  host_port:container_port  …
$ docker ps
CONTAINER ID IMAGE COMMAND STATUS PORTS
40dd6835e358 nginx:latest "nginx … Up 1 minute 443/tcp

0.0.0.0:10080->80/tcp
$  docker  ps
$  docker  run  -­‐P|-­‐p  [argument,  …]
$ docker run -d -P nginx:latest
Unable to find image 'nginx:latest' locally
latest: Pulling from nginx
39bb80489af7: Pull complete
……
72d73c46937a: Pull complete
Status: Downloaded newer image for nginx:latest
23e601370946fc9fbdfd6204e1bf70e88e6c18078a0c6ee8640acd2e6694b645
$  docker  run  -­‐d  -­‐P  image  execute  [argument,  …]
$ docker ps
CONTAINER ID IMAGE COMMAND STATUS PORTS
23e601370946 nginx:latest "nginx … Up 1 minute 0.0.0.0:32768->443/tcp

0.0.0.0:32769->80/tcp
$  docker  ps
$ boot2socker ip
192.168.59.103
$  boot2ocker  ip
$ docker run -d -p 80 nginx:latest
40dd6835e35843fdc1853e92b9922f6406f874793c085e1f71cb3967e1157cf3
$  docker  run  -­‐d  -­‐p  container_port  …
$ docker ps
CONTAINER ID IMAGE COMMAND STATUS PORTS
40dd6835e358 nginx:latest "nginx … Up 1 minute 443/tcp

0.0.0.0:32770->80/tcp
$  docker  ps
$ docker run -d -p 10080:80 nginx:latest
40dd6835e35843fdc1853e92b9922f6406f874793c085e1f71cb3967e1157cf3
$  docker  run  -­‐d  -­‐p  host_port:container_port  …
$ docker ps
CONTAINER ID IMAGE COMMAND STATUS PORTS
40dd6835e358 nginx:latest "nginx … Up 1 minute 443/tcp

0.0.0.0:10080->80/tcp
$  docker  ps
$  docker  start|restart|stop|kill  contanter
$ docker stop nginx_container
nginx_container
$  docker  stop  [container  ID/Name]
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
$  docker  ps
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
23e601370946 nginx:latest "nginx … 2 minutes ago EXITED(0) nginx_container
$  docker  ps  -­‐a
$ docker start nginx_container
nginx_container
$  docker  start  [container  ID/Name]
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
23e601370946 nginx:latest "nginx … 10 minutes ago Up 1 minute nginx_container
$  docker  ps
$ docker restart nginx_container
nginx_container
$  docker  restart  [container  ID/Name]
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
23e601370946 nginx:latest "nginx … 15 minutes ago Up 1 minute insane_babbage
$  docker  ps
$ docker stop nginx_container
nginx_container
$ docker kill nginx_container
nginx_container
$  docker  kill  [container  ID/Name]
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
$  docker  ps  -­‐a
$  docker  images|pull|rmi
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
nginx latest a785ba7493fd 16 hours ago 132.9 MB
$  docker  images
$ docker pull mysql:latest
latest: Pulling from mysql
7a3e804ed6c0: Pull complete
……
ff78d9bb5f46: Already exists
Status: Downloaded newer image for mysql:latest
$  docker  pull  image_name:tag
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
nginx latest a785ba7493fd 16 hours ago 132.9 MB
mysql latest ff78d9bb5f46 3 days ago 282.9 MB
$  docker  images
$ docker rmi mysql:latest
Untagged: mysql:latest
Deleted: ff78d9bb5f46b3a619310a8e3f3e62b98ce08b476d0d5d4088f1853d604f8218
……
Deleted: 7a3e804ed6c015465a6cb957d032276dbff7ba8582153c38b83acd70ffdad0c6
$  docker  rmi  image_name:tag|image_id
69
#  curl  -­‐L  https://github.com/docker/compose/releases/……  >  /usr/local/bin/docker-­‐compose  
#  chmod  +x  /usr/local/bin/docker-­‐compose
$  sudo  pip  install  -­‐U  docker-­‐compose
# docker-compose.yml
web:
build: .
command: python app.py
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
# docker-compose.yml
service:
...
ports:
- "3000"
- "8000:8000"
- "49100:22"
- "127.0.0.1:8001:8001"
# docker-compose.yml
service:
…
volumes:
- /var/lib/mysql
- cache/:/tmp/cache
- ~/configs:/etc/configs/:ro
# docker-compose.yml
service:
...
environment:
RACK_ENV: development
SESSION_SECRET:
environment:
- RACK_ENV=development
- SESSION_SECRET
$ docker-compose up -d
Creating swl_service_1…
$ docker-compose up -d
Recreating swl_service_1…
$ docker-compose up -d --no-recreate
$  docker-­‐compose  up  -­‐d
$ docker-compose stop
Stopping swl_service_1...
$  docker-­‐compose  stop
$ docker-compose start
Starting swl_service_1...
$  docker-­‐compose  start
$ docker-compose restart
Restarting swl_service_1...
$  docker-­‐compose  restart
$ docker-compose rm
No stopped containers
$ docker-compose stop && docker-compose rm
Going to remove swl_service_1
Are you sure? [yN] y
Removing swl_service_1...
$  docker-­‐compose  rm
80
82
83
84

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Docker composeで開発環境をメンバに配布せよ
Docker composeで開発環境をメンバに配布せよDocker composeで開発環境をメンバに配布せよ
Docker composeで開発環境をメンバに配布せよ
 
Hide your development environment and application in a container
Hide your development environment and application in a containerHide your development environment and application in a container
Hide your development environment and application in a container
 
Docker All The Things - ASP.NET 4.x and Windows Server Containers
Docker All The Things - ASP.NET 4.x and Windows Server ContainersDocker All The Things - ASP.NET 4.x and Windows Server Containers
Docker All The Things - ASP.NET 4.x and Windows Server Containers
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
 
[DockerCon 2019] Hardening Docker daemon with Rootless mode
[DockerCon 2019] Hardening Docker daemon with Rootless mode[DockerCon 2019] Hardening Docker daemon with Rootless mode
[DockerCon 2019] Hardening Docker daemon with Rootless mode
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
Austin - Container Days - Docker 101
Austin - Container Days - Docker 101Austin - Container Days - Docker 101
Austin - Container Days - Docker 101
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
 
Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on Docker
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
Docker 導入:障礙與對策
Docker 導入:障礙與對策Docker 導入:障礙與對策
Docker 導入:障礙與對策
 
DCSF 19 Deploying Rootless buildkit on Kubernetes
DCSF 19 Deploying Rootless buildkit on KubernetesDCSF 19 Deploying Rootless buildkit on Kubernetes
DCSF 19 Deploying Rootless buildkit on Kubernetes
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
 
Docker 進階實務班
Docker 進階實務班Docker 進階實務班
Docker 進階實務班
 
Docker1.12イングレスロードバランサ
Docker1.12イングレスロードバランサDocker1.12イングレスロードバランサ
Docker1.12イングレスロードバランサ
 
QNAP COSCUP Container Station
QNAP COSCUP Container StationQNAP COSCUP Container Station
QNAP COSCUP Container Station
 
RKT
RKTRKT
RKT
 
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
Continuous Delivery Workshop with Ansible x GitLab CI (2nd+)
 
Docker and DevOps --- new IT culture
Docker and DevOps --- new IT cultureDocker and DevOps --- new IT culture
Docker and DevOps --- new IT culture
 

Andere mochten auch (7)

Docker 基礎介紹與實戰
Docker 基礎介紹與實戰Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
 
認識那條鯨魚 Docker 初探
認識那條鯨魚   Docker 初探認識那條鯨魚   Docker 初探
認識那條鯨魚 Docker 初探
 
Docker應用
Docker應用Docker應用
Docker應用
 
Docker初识
Docker初识Docker初识
Docker初识
 
Docker home ted
Docker home tedDocker home ted
Docker home ted
 
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16 What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
 
用 Go 語言 打造微服務架構
用 Go 語言打造微服務架構用 Go 語言打造微服務架構
用 Go 語言 打造微服務架構
 

Ähnlich wie Docker 初探,實驗室中的運貨鯨

Ähnlich wie Docker 初探,實驗室中的運貨鯨 (20)

Docker practice
Docker practiceDocker practice
Docker practice
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOps
 
Azure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish KalamatiAzure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish Kalamati
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
Docker orchestration v4
Docker orchestration v4Docker orchestration v4
Docker orchestration v4
 
Docker orchestration
Docker orchestrationDocker orchestration
Docker orchestration
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Docker 1.12 and SwarmKit
Docker 1.12 and SwarmKitDocker 1.12 and SwarmKit
Docker 1.12 and SwarmKit
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
New Docker Features for Orchestration and Containers
New Docker Features for Orchestration and ContainersNew Docker Features for Orchestration and Containers
New Docker Features for Orchestration and Containers
 
The How and Why of Windows containers
The How and Why of Windows containersThe How and Why of Windows containers
The How and Why of Windows containers
 
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea LuzzardiWhat's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
 
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
What's New in Docker 1.12 by Mike Goelzer and Andrea LuzzardiWhat's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
 
Things I've learned working with Docker Support
Things I've learned working with Docker SupportThings I've learned working with Docker Support
Things I've learned working with Docker Support
 
Adrian Mouat - Docker Tips and Tricks
 Adrian Mouat - Docker Tips and Tricks Adrian Mouat - Docker Tips and Tricks
Adrian Mouat - Docker Tips and Tricks
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Docker 初探,實驗室中的運貨鯨

  • 1. 1
  • 2. 2
  • 6.
  • 9. 9
  • 10.
  • 11. 11
  • 12.
  • 13. 13
  • 14.
  • 15. $  wget  -­‐qO-­‐  https://get.docker.com/  |  sh
  • 17.
  • 18. 18
  • 19.
  • 20. $  [sudo]  docker  [command]  [flags]  [arguments]
  • 21. $ docker Commands: attach Attach to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes $  docker
  • 22. $ docker version Client version: 1.62 Client API version: 1.18 Go version (client): go1.4.1 Git commit (client): a8a31ef OS/Arch (client): darwin/amd64 Server version: 1.6.2 Server API version: 1.18 Go version (server): go1.4.2 Git commit (server): 4749651 $  docker  version
  • 23. $ docker info Containers: 3 Images: 65 Storage Driver: aufs Root Dir: /mnt/sda1/var/lib/docker/aufs … Execution Driver: native-0.2 Kernel Version: 4.0.3-boot2docker Operating System: Boot2Docker 1.6.2 (TCL 5.4); …… $  docker  info
  • 24. $ docker run --help Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container …… $  docker  command  -­‐-­‐help
  • 25.
  • 26. $  docker  run  image  execute  [argument,  …]
  • 27. $ docker run ubuntu:14.04 /bin/echo 'Hello world' Hello world $  docker  run  image  execute  [argument,  …]
  • 28. $ docker run -it ubuntu:14.04 /bin/bash root@af8bae53bdd3:/# $  docker  run  -­‐it  image  execute  [argument,  …]
  • 29. $ docker run -d ubuntu:14.04 /bin/echo 
 -c "while true; do echo hello world; sleep 1; done" 1e5535038e285177d5214659a068137486f96ee5c2e85a4ac52dc83f2ebe4147 $  docker  run  -­‐d  image  execute  [argument,  …]
  • 30. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES 1e5535038e28 ubuntu:14.04 /bin/sh… 2 minutes ago Up 1 minute insane_babbage $  docker  ps
  • 31. $ docker logs 1e5535038e28 hello world hello world hello world $  docker  logs  [container  ID/Name]
  • 32. $ docker logs insane_babbage hello world hello world hello world $  docker  logs  [container  ID/Name]
  • 33. $  docker  run  -­‐P|-­‐p  …
  • 34. $ docker run -d -P nginx:latest Unable to find image 'nginx:latest' locally latest: Pulling from nginx 39bb80489af7: Pull complete …… 72d73c46937a: Pull complete Status: Downloaded newer image for nginx:latest 23e601370946fc9fbdfd6204e1bf70e88e6c18078a0c6ee8640acd2e6694b645 $  docker  run  -­‐d  -­‐P  image  execute  [argument,  …]
  • 35. $ docker ps CONTAINER ID IMAGE COMMAND STATUS PORTS 23e601370946 nginx:latest "nginx … Up 1 minute 0.0.0.0:32768->443/tcp
 0.0.0.0:32769->80/tcp $  docker  ps
  • 37.
  • 38. $ docker run -d -p 80 nginx:latest 40dd6835e35843fdc1853e92b9922f6406f874793c085e1f71cb3967e1157cf3 $  docker  run  -­‐d  -­‐p  container_port  …
  • 39. $ docker ps CONTAINER ID IMAGE COMMAND STATUS PORTS 40dd6835e358 nginx:latest "nginx … Up 1 minute 443/tcp
 0.0.0.0:32770->80/tcp $  docker  ps
  • 40. $ docker run -d -p 10080:80 nginx:latest 40dd6835e35843fdc1853e92b9922f6406f874793c085e1f71cb3967e1157cf3 $  docker  run  -­‐d  -­‐p  host_port:container_port  …
  • 41. $ docker ps CONTAINER ID IMAGE COMMAND STATUS PORTS 40dd6835e358 nginx:latest "nginx … Up 1 minute 443/tcp
 0.0.0.0:10080->80/tcp $  docker  ps
  • 42. $  docker  run  -­‐P|-­‐p  [argument,  …]
  • 43. $ docker run -d -P nginx:latest Unable to find image 'nginx:latest' locally latest: Pulling from nginx 39bb80489af7: Pull complete …… 72d73c46937a: Pull complete Status: Downloaded newer image for nginx:latest 23e601370946fc9fbdfd6204e1bf70e88e6c18078a0c6ee8640acd2e6694b645 $  docker  run  -­‐d  -­‐P  image  execute  [argument,  …]
  • 44. $ docker ps CONTAINER ID IMAGE COMMAND STATUS PORTS 23e601370946 nginx:latest "nginx … Up 1 minute 0.0.0.0:32768->443/tcp
 0.0.0.0:32769->80/tcp $  docker  ps
  • 46.
  • 47. $ docker run -d -p 80 nginx:latest 40dd6835e35843fdc1853e92b9922f6406f874793c085e1f71cb3967e1157cf3 $  docker  run  -­‐d  -­‐p  container_port  …
  • 48. $ docker ps CONTAINER ID IMAGE COMMAND STATUS PORTS 40dd6835e358 nginx:latest "nginx … Up 1 minute 443/tcp
 0.0.0.0:32770->80/tcp $  docker  ps
  • 49. $ docker run -d -p 10080:80 nginx:latest 40dd6835e35843fdc1853e92b9922f6406f874793c085e1f71cb3967e1157cf3 $  docker  run  -­‐d  -­‐p  host_port:container_port  …
  • 50. $ docker ps CONTAINER ID IMAGE COMMAND STATUS PORTS 40dd6835e358 nginx:latest "nginx … Up 1 minute 443/tcp
 0.0.0.0:10080->80/tcp $  docker  ps
  • 52. $ docker stop nginx_container nginx_container $  docker  stop  [container  ID/Name]
  • 53. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES $  docker  ps
  • 54. $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES 23e601370946 nginx:latest "nginx … 2 minutes ago EXITED(0) nginx_container $  docker  ps  -­‐a
  • 55. $ docker start nginx_container nginx_container $  docker  start  [container  ID/Name]
  • 56. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES 23e601370946 nginx:latest "nginx … 10 minutes ago Up 1 minute nginx_container $  docker  ps
  • 57. $ docker restart nginx_container nginx_container $  docker  restart  [container  ID/Name]
  • 58. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES 23e601370946 nginx:latest "nginx … 15 minutes ago Up 1 minute insane_babbage $  docker  ps
  • 59. $ docker stop nginx_container nginx_container $ docker kill nginx_container nginx_container $  docker  kill  [container  ID/Name]
  • 60. $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES $  docker  ps  -­‐a
  • 62. $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE nginx latest a785ba7493fd 16 hours ago 132.9 MB $  docker  images
  • 63. $ docker pull mysql:latest latest: Pulling from mysql 7a3e804ed6c0: Pull complete …… ff78d9bb5f46: Already exists Status: Downloaded newer image for mysql:latest $  docker  pull  image_name:tag
  • 64. $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE nginx latest a785ba7493fd 16 hours ago 132.9 MB mysql latest ff78d9bb5f46 3 days ago 282.9 MB $  docker  images
  • 65. $ docker rmi mysql:latest Untagged: mysql:latest Deleted: ff78d9bb5f46b3a619310a8e3f3e62b98ce08b476d0d5d4088f1853d604f8218 …… Deleted: 7a3e804ed6c015465a6cb957d032276dbff7ba8582153c38b83acd70ffdad0c6 $  docker  rmi  image_name:tag|image_id
  • 66.
  • 67.
  • 68.
  • 69. 69
  • 70. #  curl  -­‐L  https://github.com/docker/compose/releases/……  >  /usr/local/bin/docker-­‐compose   #  chmod  +x  /usr/local/bin/docker-­‐compose $  sudo  pip  install  -­‐U  docker-­‐compose
  • 71. # docker-compose.yml web: build: . command: python app.py ports: - "5000:5000" volumes: - .:/code links: - redis
  • 72. # docker-compose.yml service: ... ports: - "3000" - "8000:8000" - "49100:22" - "127.0.0.1:8001:8001"
  • 73. # docker-compose.yml service: … volumes: - /var/lib/mysql - cache/:/tmp/cache - ~/configs:/etc/configs/:ro
  • 75. $ docker-compose up -d Creating swl_service_1… $ docker-compose up -d Recreating swl_service_1… $ docker-compose up -d --no-recreate $  docker-­‐compose  up  -­‐d
  • 76. $ docker-compose stop Stopping swl_service_1... $  docker-­‐compose  stop
  • 77. $ docker-compose start Starting swl_service_1... $  docker-­‐compose  start
  • 78. $ docker-compose restart Restarting swl_service_1... $  docker-­‐compose  restart
  • 79. $ docker-compose rm No stopped containers $ docker-compose stop && docker-compose rm Going to remove swl_service_1 Are you sure? [yN] y Removing swl_service_1... $  docker-­‐compose  rm
  • 80. 80
  • 81.
  • 82. 82
  • 83. 83
  • 84. 84