SlideShare a Scribd company logo
Managing Docker Containers 
creating, killing, restarting and removing containers 
27 August 2014 
Loh Siu Yin 
Technology Consultant, Beyond Broadcast LLP 
1 of 19
Why Docker? 
Docker is a good way to deploy a 12 factor app. 
The twelve-factor app is a methodology for building software-as-a-service apps that: 
Use declarative formats for setup automation, to minimize time and cost for new 
developers joining the project; [dockerfile] 
Have a clean contract with the underlying operating system, offering maximum 
portability between execution environments; [container] 
Are suitable for deployment on modern cloud platforms, obviating the need for 
servers and systems administration; (yes) 
Minimize divergence between development and production, enabling continuous 
deployment for maximum agility; (yes) 
And can scale up without significant changes to tooling, architecture, or 
development practices. (yes) 
12factor.net (http://12factor.net) 
2 of 19
Docker 
Docker allows you to package your application into a Docker container. 
This container can then be run on any Linux host running kernel 3.8 or above (RHEL 
6.5 with kernel 2.6.32-431 is also supported). 
docker.com gives instructions for installing Docker on a variety of platforms. 
To get help, run the docker command without arguments 
docker.com (http://docker.com) 
3 of 19
Script to create and run a Docker container 
#!/bin/bash 
echo "Launching docker container named: ger" 
docker run --name ger -d  
-e DEEP='blue/green algae'  
-e GER=bau  
ubuntu /bin/bash -c 'while true; do  
echo $DEEP;  
echo $GER;  
echo `date`;  
sleep 3; 
done' Run 
--name ger names the container to be created ger 
-d daemonize 
-e defines an environment variable to be applied to the container. There is also 
--env-file if you have lots of variables. 
ubuntu is the name of a Docker image from which the container will be created 
4 of 19
Viewing a container's log 
#!/bin/bash 
echo "attaching to ger" 
docker logs ger Run 
re-run script with -t 
Docker captures your app's stdout and stderr into a json formatted log on the Docker 
host at /var/lib/docker/containers/{container_id} 
docker logs reads the json format log file in the container's folder on the host and 
presents it. 
The log files on the host are not automatically rotated. Setup logrotate on the Docker 
host to achieve this. 
5 of 19
Docker images 
6 of 19
Docker Image v. Container 
A Docker image is a software build. 
Say you have an SMTP server docker image named "postfix". This image is the 
executable file that can run on any Docker host. 
--- 
A Docker container is a deployment (configuration + build). Say you want an email 
server at example.com. So we take the postfix image and bind it to a configuration (the 
address: example.com). 
However it does not become a Docker container until you run it, creating the container 
from the image in the process. 
You now have example.com's email server running in a Docker container. When you 
stop the container you stop example.com's email server. 
7 of 19
About Docker images 
You download or pull images from hub.docker.com (think of it as github for Docker 
images). You can also run your own image registry. Docker registry is Open Source. 
You build your own Docker image for your application from a dockerfile you write 
or by commit ing a container you've created. 
push your Docker image to the Docker registry. If you have previously pushed an 
earlier version of your image, only the changes are pushed. Again think of applying a 
diff to your github repository. 
Similarly if you have pulled an ealier version of the image, updating the image 
involves downloading only the changed bits. 
docs.docker.com (http://docs.docker.com) 
8 of 19
Commit a container run to an image 
#!/bin/bash 
echo "committing ger to new image siuyin/ger:20140827" 
docker commit ger siuyin/ger:20140827 Run 
9 of 19
Running the image 
#!/bin/sh 
echo "creating and running container: ger1" 
docker run --name ger1 -d  
-e DEEP=purple  
-e GER=bear  
siuyin/ger:20140827 Run 
10 of 19
Back to Docker containers 
11 of 19
But first wdotweb 
wdotweb is a web application that provides a workflow charting service over a 
user-configured http port. 
#!/bin/bash 
docker run --name wdot -d  
-p 3322:22  
-p 8288:8188  
siuyin/wdotweb:20140820 Run 
docker ps to show exposed ports 
12 of 19
Listing Docker containers 
#!/bin/bash 
# list all docker processes (containers) including stopped ones: -a 
docker ps Run 
first run the above script without -a 
CONTAINER ID is a unique id for each Docker container. Docker commands to 
manage a container require either an ID or name to be specified. It is usually 
sufficient to refer to the container with the first 3 or 4 letters of the ID. 
IMAGE is the Docker image the container was built from 
NAMES is the human friendly name you can use to refer to the container rather 
than using the ID. 
13 of 19
Stopping a container 
#!/bin/bash 
echo "stopping ger" 
docker stop -t 3 ger Run 
docker stop: 
Stop a running container (send SIGTERM, and then SIGKILL after grace period 
default 10s, specified 3s above) 
The main process inside the container will receive SIGTERM, and after a grace period, 
SIGKILL. 
Useful feature: 
The docker daemon on the Docker host will restart containers that were running when 
the host is restarted. 
14 of 19
Killing a container 
#!/bin/bash 
echo "killing ger" 
docker kill ger Run 
docker kill: 
Kill a running container (send SIGKILL, or specified signal) [...] 
The main process inside the container will be sent SIGKILL, or any signal specified with 
option --signal. 
15 of 19
Restarting a stopped or killed container 
#!/bin/sh 
echo "starting ger" 
docker start ger Run 
If you run docker ps now you will see the container ger running. 
docker start is idempotent. It is OK to start a container that has already been started. 
16 of 19
Removing a container 
#!/bin/sh 
echo "removing ger" 
docker rm ger Run 
docker rm deletes the container and all its associated files. 
After rm, the container named ger is deleted and a newly created container can reuse 
the name ger. 
17 of 19
Slides Download 
Slides available at : 
www.slideshare.net/siuyin (http://www.slideshare.net/siuyin) 
18 of 19
Thank you 
Loh Siu Yin 
Technology Consultant, Beyond Broadcast LLP 
siuyin@beyondbroadcast.com (mailto:siuyin@beyondbroadcast.com) 
19 of 19

More Related Content

What's hot

Revolutionizing WSO2 PaaS with Kubernetes & App Factory
Revolutionizing WSO2 PaaS with Kubernetes & App FactoryRevolutionizing WSO2 PaaS with Kubernetes & App Factory
Revolutionizing WSO2 PaaS with Kubernetes & App Factory
Imesh Gunaratne
 
WSO2Con ASIA 2016: WSO2 Cloud Strategy Update
WSO2Con ASIA 2016: WSO2 Cloud Strategy UpdateWSO2Con ASIA 2016: WSO2 Cloud Strategy Update
WSO2Con ASIA 2016: WSO2 Cloud Strategy Update
WSO2
 
Diagnose Your Microservices
Diagnose Your MicroservicesDiagnose Your Microservices
Diagnose Your Microservices
Marcus Hirt
 
Docker Meetup - Melbourne 2015 - Kubernetes Deep Dive
Docker Meetup - Melbourne 2015 - Kubernetes Deep DiveDocker Meetup - Melbourne 2015 - Kubernetes Deep Dive
Docker Meetup - Melbourne 2015 - Kubernetes Deep Dive
Ken Thompson
 
Docker containerd Kubernetes sig node
Docker containerd Kubernetes sig nodeDocker containerd Kubernetes sig node
Docker containerd Kubernetes sig node
Patrick Chanezon
 
Containers in production with docker, coreos, kubernetes and apache stratos
Containers in production with docker, coreos, kubernetes and apache stratosContainers in production with docker, coreos, kubernetes and apache stratos
Containers in production with docker, coreos, kubernetes and apache stratos
WSO2
 
Openshift linuxday 2014
Openshift linuxday 2014Openshift linuxday 2014
Openshift linuxday 2014
Massimiliano Dessì
 
Open stack nova reverse engineer
Open stack nova reverse engineerOpen stack nova reverse engineer
Open stack nova reverse engineer
Vietnam Open Infrastructure User Group
 
DockerCon 2016 Recap
DockerCon 2016 RecapDockerCon 2016 Recap
DockerCon 2016 Recap
Jochen Zehnder
 
Containers without docker
Containers without dockerContainers without docker
Containers without docker
Ben Hall
 
Online Meetup: What's new in docker 1.13.0
Online Meetup: What's new in docker 1.13.0 Online Meetup: What's new in docker 1.13.0
Online Meetup: What's new in docker 1.13.0
Docker, Inc.
 
Understanding Kubernetes
Understanding KubernetesUnderstanding Kubernetes
Understanding Kubernetes
Tu Pham
 
Rkt Container Engine
Rkt Container EngineRkt Container Engine
Rkt Container Engine
Thuc Le Dong
 
How to build a Kubernetes networking solution from scratch
How to build a Kubernetes networking solution from scratchHow to build a Kubernetes networking solution from scratch
How to build a Kubernetes networking solution from scratch
All Things Open
 
Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2
Imesh Gunaratne
 
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Phil Estes
 
containerd the universal container runtime
containerd the universal container runtimecontainerd the universal container runtime
containerd the universal container runtime
Docker, Inc.
 
Global Persistence for Docker
Global Persistence for DockerGlobal Persistence for Docker
Global Persistence for Docker
Docker, Inc.
 
Private PaaS for the Enterprise - Apache Stratos & WSO2 Private PaaS
Private PaaS for the Enterprise - Apache Stratos & WSO2 Private PaaSPrivate PaaS for the Enterprise - Apache Stratos & WSO2 Private PaaS
Private PaaS for the Enterprise - Apache Stratos & WSO2 Private PaaS
Imesh Gunaratne
 
Back to the Future: Containerize Legacy Applications
Back to the Future: Containerize Legacy ApplicationsBack to the Future: Containerize Legacy Applications
Back to the Future: Containerize Legacy Applications
Docker, Inc.
 

What's hot (20)

Revolutionizing WSO2 PaaS with Kubernetes & App Factory
Revolutionizing WSO2 PaaS with Kubernetes & App FactoryRevolutionizing WSO2 PaaS with Kubernetes & App Factory
Revolutionizing WSO2 PaaS with Kubernetes & App Factory
 
WSO2Con ASIA 2016: WSO2 Cloud Strategy Update
WSO2Con ASIA 2016: WSO2 Cloud Strategy UpdateWSO2Con ASIA 2016: WSO2 Cloud Strategy Update
WSO2Con ASIA 2016: WSO2 Cloud Strategy Update
 
Diagnose Your Microservices
Diagnose Your MicroservicesDiagnose Your Microservices
Diagnose Your Microservices
 
Docker Meetup - Melbourne 2015 - Kubernetes Deep Dive
Docker Meetup - Melbourne 2015 - Kubernetes Deep DiveDocker Meetup - Melbourne 2015 - Kubernetes Deep Dive
Docker Meetup - Melbourne 2015 - Kubernetes Deep Dive
 
Docker containerd Kubernetes sig node
Docker containerd Kubernetes sig nodeDocker containerd Kubernetes sig node
Docker containerd Kubernetes sig node
 
Containers in production with docker, coreos, kubernetes and apache stratos
Containers in production with docker, coreos, kubernetes and apache stratosContainers in production with docker, coreos, kubernetes and apache stratos
Containers in production with docker, coreos, kubernetes and apache stratos
 
Openshift linuxday 2014
Openshift linuxday 2014Openshift linuxday 2014
Openshift linuxday 2014
 
Open stack nova reverse engineer
Open stack nova reverse engineerOpen stack nova reverse engineer
Open stack nova reverse engineer
 
DockerCon 2016 Recap
DockerCon 2016 RecapDockerCon 2016 Recap
DockerCon 2016 Recap
 
Containers without docker
Containers without dockerContainers without docker
Containers without docker
 
Online Meetup: What's new in docker 1.13.0
Online Meetup: What's new in docker 1.13.0 Online Meetup: What's new in docker 1.13.0
Online Meetup: What's new in docker 1.13.0
 
Understanding Kubernetes
Understanding KubernetesUnderstanding Kubernetes
Understanding Kubernetes
 
Rkt Container Engine
Rkt Container EngineRkt Container Engine
Rkt Container Engine
 
How to build a Kubernetes networking solution from scratch
How to build a Kubernetes networking solution from scratchHow to build a Kubernetes networking solution from scratch
How to build a Kubernetes networking solution from scratch
 
Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2
 
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
 
containerd the universal container runtime
containerd the universal container runtimecontainerd the universal container runtime
containerd the universal container runtime
 
Global Persistence for Docker
Global Persistence for DockerGlobal Persistence for Docker
Global Persistence for Docker
 
Private PaaS for the Enterprise - Apache Stratos & WSO2 Private PaaS
Private PaaS for the Enterprise - Apache Stratos & WSO2 Private PaaSPrivate PaaS for the Enterprise - Apache Stratos & WSO2 Private PaaS
Private PaaS for the Enterprise - Apache Stratos & WSO2 Private PaaS
 
Back to the Future: Containerize Legacy Applications
Back to the Future: Containerize Legacy ApplicationsBack to the Future: Containerize Legacy Applications
Back to the Future: Containerize Legacy Applications
 

Viewers also liked

Smith, Terri Presentation Evaluation 2014-11-1
Smith, Terri Presentation Evaluation 2014-11-1Smith, Terri Presentation Evaluation 2014-11-1
Smith, Terri Presentation Evaluation 2014-11-1
CSU Fresno
 
A2Z in Relationship
A2Z in RelationshipA2Z in Relationship
A2Z in Relationship
CA Hemant C. Lodha
 
Final project strategies that work to increase students’ reading
Final project   strategies that work to increase students’ readingFinal project   strategies that work to increase students’ reading
Final project strategies that work to increase students’ reading
CSU Fresno
 
Action Research Y R I B A R R E N R
Action Research Y R I B A R R E N RAction Research Y R I B A R R E N R
Action Research Y R I B A R R E N R
CSU Fresno
 
Animais em extinção!!!juju ejuju
Animais em extinção!!!juju ejujuAnimais em extinção!!!juju ejuju
Animais em extinção!!!juju ejujuNute Jpa
 
A2Z for Life
A2Z for LifeA2Z for Life
A2Z for Life
CA Hemant C. Lodha
 
CAFE (Child Adoption For Education
CAFE (Child Adoption For EducationCAFE (Child Adoption For Education
CAFE (Child Adoption For Education
CA Hemant C. Lodha
 
A to Z about Leadership
A to Z about LeadershipA to Z about Leadership
A to Z about Leadership
CA Hemant C. Lodha
 
Final project strategies that work to increase students’ reading
Final project   strategies that work to increase students’ readingFinal project   strategies that work to increase students’ reading
Final project strategies that work to increase students’ reading
CSU Fresno
 
Container Deployment and Management with kubernetes
Container Deployment and Management with kubernetesContainer Deployment and Management with kubernetes
Container Deployment and Management with kubernetes
siuyin
 
Final project strategies that work to increase students’ reading
Final project   strategies that work to increase students’ readingFinal project   strategies that work to increase students’ reading
Final project strategies that work to increase students’ reading
CSU Fresno
 
Developing Successful Virtual Learning Environments in the Baltimore County...
Developing Successful Virtual Learning Environments in the Baltimore County...Developing Successful Virtual Learning Environments in the Baltimore County...
Developing Successful Virtual Learning Environments in the Baltimore County...
LJ
 
A2Z Entrepreneurship
A2Z EntrepreneurshipA2Z Entrepreneurship
A2Z Entrepreneurship
CA Hemant C. Lodha
 
A2ZLeadership
A2ZLeadershipA2ZLeadership
A2ZLeadership
CA Hemant C. Lodha
 
Cooperative Learning
Cooperative LearningCooperative Learning
Cooperative Learning
CSU Fresno
 
Go concurrency
Go concurrencyGo concurrency
Go concurrency
siuyin
 
26 characterstics - A2Z in Entrepreneurship
26 characterstics - A2Z in Entrepreneurship26 characterstics - A2Z in Entrepreneurship
26 characterstics - A2Z in Entrepreneurship
CA Hemant C. Lodha
 
8 elements of achieving organisational performance
8 elements of achieving organisational performance8 elements of achieving organisational performance
8 elements of achieving organisational performance
CA Hemant C. Lodha
 
Prezentacja Zabawa Integracyjna
Prezentacja Zabawa IntegracyjnaPrezentacja Zabawa Integracyjna
Prezentacja Zabawa IntegracyjnaAleksandraJ
 

Viewers also liked (19)

Smith, Terri Presentation Evaluation 2014-11-1
Smith, Terri Presentation Evaluation 2014-11-1Smith, Terri Presentation Evaluation 2014-11-1
Smith, Terri Presentation Evaluation 2014-11-1
 
A2Z in Relationship
A2Z in RelationshipA2Z in Relationship
A2Z in Relationship
 
Final project strategies that work to increase students’ reading
Final project   strategies that work to increase students’ readingFinal project   strategies that work to increase students’ reading
Final project strategies that work to increase students’ reading
 
Action Research Y R I B A R R E N R
Action Research Y R I B A R R E N RAction Research Y R I B A R R E N R
Action Research Y R I B A R R E N R
 
Animais em extinção!!!juju ejuju
Animais em extinção!!!juju ejujuAnimais em extinção!!!juju ejuju
Animais em extinção!!!juju ejuju
 
A2Z for Life
A2Z for LifeA2Z for Life
A2Z for Life
 
CAFE (Child Adoption For Education
CAFE (Child Adoption For EducationCAFE (Child Adoption For Education
CAFE (Child Adoption For Education
 
A to Z about Leadership
A to Z about LeadershipA to Z about Leadership
A to Z about Leadership
 
Final project strategies that work to increase students’ reading
Final project   strategies that work to increase students’ readingFinal project   strategies that work to increase students’ reading
Final project strategies that work to increase students’ reading
 
Container Deployment and Management with kubernetes
Container Deployment and Management with kubernetesContainer Deployment and Management with kubernetes
Container Deployment and Management with kubernetes
 
Final project strategies that work to increase students’ reading
Final project   strategies that work to increase students’ readingFinal project   strategies that work to increase students’ reading
Final project strategies that work to increase students’ reading
 
Developing Successful Virtual Learning Environments in the Baltimore County...
Developing Successful Virtual Learning Environments in the Baltimore County...Developing Successful Virtual Learning Environments in the Baltimore County...
Developing Successful Virtual Learning Environments in the Baltimore County...
 
A2Z Entrepreneurship
A2Z EntrepreneurshipA2Z Entrepreneurship
A2Z Entrepreneurship
 
A2ZLeadership
A2ZLeadershipA2ZLeadership
A2ZLeadership
 
Cooperative Learning
Cooperative LearningCooperative Learning
Cooperative Learning
 
Go concurrency
Go concurrencyGo concurrency
Go concurrency
 
26 characterstics - A2Z in Entrepreneurship
26 characterstics - A2Z in Entrepreneurship26 characterstics - A2Z in Entrepreneurship
26 characterstics - A2Z in Entrepreneurship
 
8 elements of achieving organisational performance
8 elements of achieving organisational performance8 elements of achieving organisational performance
8 elements of achieving organisational performance
 
Prezentacja Zabawa Integracyjna
Prezentacja Zabawa IntegracyjnaPrezentacja Zabawa Integracyjna
Prezentacja Zabawa Integracyjna
 

Similar to Managing Docker containers

Docker @ Atlogys
Docker @ AtlogysDocker @ Atlogys
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
CloudHero
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
Araf Karsh Hamid
 
Docker
DockerDocker
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
Dr. Syed Hassan Amin
 
Tips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podmanTips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podman
Thierry Gayet
 
Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
nigamsajal14
 
docker.pdf
docker.pdfdocker.pdf
docker.pdf
EishaTirRaazia1
 
Docker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini AnandDocker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini Anand
PRIYADARSHINI ANAND
 
Docker.pdf
Docker.pdfDocker.pdf
Docker.pdf
UsamaMushtaq24
 
Bring Continuous Integration to Your Laptop With the Drone CI Docker Extensio...
Bring Continuous Integration to Your Laptop With the Drone CI Docker Extensio...Bring Continuous Integration to Your Laptop With the Drone CI Docker Extensio...
Bring Continuous Integration to Your Laptop With the Drone CI Docker Extensio...
jemije2490
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
JasonStraughan1
 
Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2
Binary Studio
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
Binary Studio
 
Primi passi con Docker - ItalianCoders - 12-01-2021
Primi passi con Docker - ItalianCoders - 12-01-2021Primi passi con Docker - ItalianCoders - 12-01-2021
Primi passi con Docker - ItalianCoders - 12-01-2021
Alessandro Mignogna
 
Docker
DockerDocker
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Jim Yeh
 
Talk about Docker
Talk about DockerTalk about Docker
Talk about Docker
Meng-Ze Lee
 
Docker
DockerDocker
Let's dockerize
Let's dockerizeLet's dockerize
Let's dockerize
Ahmed Sorour
 

Similar to Managing Docker containers (20)

Docker @ Atlogys
Docker @ AtlogysDocker @ Atlogys
Docker @ Atlogys
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Docker
DockerDocker
Docker
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
 
Tips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podmanTips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podman
 
Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
 
docker.pdf
docker.pdfdocker.pdf
docker.pdf
 
Docker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini AnandDocker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini Anand
 
Docker.pdf
Docker.pdfDocker.pdf
Docker.pdf
 
Bring Continuous Integration to Your Laptop With the Drone CI Docker Extensio...
Bring Continuous Integration to Your Laptop With the Drone CI Docker Extensio...Bring Continuous Integration to Your Laptop With the Drone CI Docker Extensio...
Bring Continuous Integration to Your Laptop With the Drone CI Docker Extensio...
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
 
Primi passi con Docker - ItalianCoders - 12-01-2021
Primi passi con Docker - ItalianCoders - 12-01-2021Primi passi con Docker - ItalianCoders - 12-01-2021
Primi passi con Docker - ItalianCoders - 12-01-2021
 
Docker
DockerDocker
Docker
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Talk about Docker
Talk about DockerTalk about Docker
Talk about Docker
 
Docker
DockerDocker
Docker
 
Let's dockerize
Let's dockerizeLet's dockerize
Let's dockerize
 

Recently uploaded

20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 

Recently uploaded (20)

20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 

Managing Docker containers

  • 1. Managing Docker Containers creating, killing, restarting and removing containers 27 August 2014 Loh Siu Yin Technology Consultant, Beyond Broadcast LLP 1 of 19
  • 2. Why Docker? Docker is a good way to deploy a 12 factor app. The twelve-factor app is a methodology for building software-as-a-service apps that: Use declarative formats for setup automation, to minimize time and cost for new developers joining the project; [dockerfile] Have a clean contract with the underlying operating system, offering maximum portability between execution environments; [container] Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration; (yes) Minimize divergence between development and production, enabling continuous deployment for maximum agility; (yes) And can scale up without significant changes to tooling, architecture, or development practices. (yes) 12factor.net (http://12factor.net) 2 of 19
  • 3. Docker Docker allows you to package your application into a Docker container. This container can then be run on any Linux host running kernel 3.8 or above (RHEL 6.5 with kernel 2.6.32-431 is also supported). docker.com gives instructions for installing Docker on a variety of platforms. To get help, run the docker command without arguments docker.com (http://docker.com) 3 of 19
  • 4. Script to create and run a Docker container #!/bin/bash echo "Launching docker container named: ger" docker run --name ger -d -e DEEP='blue/green algae' -e GER=bau ubuntu /bin/bash -c 'while true; do echo $DEEP; echo $GER; echo `date`; sleep 3; done' Run --name ger names the container to be created ger -d daemonize -e defines an environment variable to be applied to the container. There is also --env-file if you have lots of variables. ubuntu is the name of a Docker image from which the container will be created 4 of 19
  • 5. Viewing a container's log #!/bin/bash echo "attaching to ger" docker logs ger Run re-run script with -t Docker captures your app's stdout and stderr into a json formatted log on the Docker host at /var/lib/docker/containers/{container_id} docker logs reads the json format log file in the container's folder on the host and presents it. The log files on the host are not automatically rotated. Setup logrotate on the Docker host to achieve this. 5 of 19
  • 7. Docker Image v. Container A Docker image is a software build. Say you have an SMTP server docker image named "postfix". This image is the executable file that can run on any Docker host. --- A Docker container is a deployment (configuration + build). Say you want an email server at example.com. So we take the postfix image and bind it to a configuration (the address: example.com). However it does not become a Docker container until you run it, creating the container from the image in the process. You now have example.com's email server running in a Docker container. When you stop the container you stop example.com's email server. 7 of 19
  • 8. About Docker images You download or pull images from hub.docker.com (think of it as github for Docker images). You can also run your own image registry. Docker registry is Open Source. You build your own Docker image for your application from a dockerfile you write or by commit ing a container you've created. push your Docker image to the Docker registry. If you have previously pushed an earlier version of your image, only the changes are pushed. Again think of applying a diff to your github repository. Similarly if you have pulled an ealier version of the image, updating the image involves downloading only the changed bits. docs.docker.com (http://docs.docker.com) 8 of 19
  • 9. Commit a container run to an image #!/bin/bash echo "committing ger to new image siuyin/ger:20140827" docker commit ger siuyin/ger:20140827 Run 9 of 19
  • 10. Running the image #!/bin/sh echo "creating and running container: ger1" docker run --name ger1 -d -e DEEP=purple -e GER=bear siuyin/ger:20140827 Run 10 of 19
  • 11. Back to Docker containers 11 of 19
  • 12. But first wdotweb wdotweb is a web application that provides a workflow charting service over a user-configured http port. #!/bin/bash docker run --name wdot -d -p 3322:22 -p 8288:8188 siuyin/wdotweb:20140820 Run docker ps to show exposed ports 12 of 19
  • 13. Listing Docker containers #!/bin/bash # list all docker processes (containers) including stopped ones: -a docker ps Run first run the above script without -a CONTAINER ID is a unique id for each Docker container. Docker commands to manage a container require either an ID or name to be specified. It is usually sufficient to refer to the container with the first 3 or 4 letters of the ID. IMAGE is the Docker image the container was built from NAMES is the human friendly name you can use to refer to the container rather than using the ID. 13 of 19
  • 14. Stopping a container #!/bin/bash echo "stopping ger" docker stop -t 3 ger Run docker stop: Stop a running container (send SIGTERM, and then SIGKILL after grace period default 10s, specified 3s above) The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL. Useful feature: The docker daemon on the Docker host will restart containers that were running when the host is restarted. 14 of 19
  • 15. Killing a container #!/bin/bash echo "killing ger" docker kill ger Run docker kill: Kill a running container (send SIGKILL, or specified signal) [...] The main process inside the container will be sent SIGKILL, or any signal specified with option --signal. 15 of 19
  • 16. Restarting a stopped or killed container #!/bin/sh echo "starting ger" docker start ger Run If you run docker ps now you will see the container ger running. docker start is idempotent. It is OK to start a container that has already been started. 16 of 19
  • 17. Removing a container #!/bin/sh echo "removing ger" docker rm ger Run docker rm deletes the container and all its associated files. After rm, the container named ger is deleted and a newly created container can reuse the name ger. 17 of 19
  • 18. Slides Download Slides available at : www.slideshare.net/siuyin (http://www.slideshare.net/siuyin) 18 of 19
  • 19. Thank you Loh Siu Yin Technology Consultant, Beyond Broadcast LLP siuyin@beyondbroadcast.com (mailto:siuyin@beyondbroadcast.com) 19 of 19