SlideShare a Scribd company logo
Docker
https://docs.docker.com/docker-for-windows/install/
1
Slide by Hao-Chun Chang
Virtual Machines
2
VM Includes a full copy of an
operating system, the
application, necessary binaries
and libraries
One VM can take up tens of
GBs.
It can be slow to boot.
https://www.docker.com/resources/what-container
Slide by Hao-Chun Chang
Why docker?
3
https://www.docker.com/resources/what-container
Slide by Hao-Chun Chang
When programs have multiple
versions.
You can create multiple
containers to prevent version
conflict.
Why docker?
4
https://www.docker.com/resources/what-container
Slide by Hao-Chun Chang
When you want to reproduce
your analysis.
Or simply transfer to a new
computer.
You can transfer the whole
container quickly.
Old
New computer
with Docker
installed
Same
environment
Workflow
https://docs.docker.com/
Slide by Hao-Chun Chang
docker pull ubuntu:16.04
docker images
docker run -it --name my_container
ubuntu:16.04 bash
docker start/stop my_container
https://hub.docker.com/_/ubuntu
docker ps -a
docker attach my_container
docker exec -it my_container bash
Image
Container
docker save/load
docker export/import
Dockerfile
docker build
Download images
List images
List containers
docker commit my_container
repo_name/my_image:v1
docker push my_container
repo_name/my_image:v1
5
Docker run
https://docs.docker.com/
Slide by Hao-Chun Chang
docker run -it 
-p 8888:1234  # [host port]:[container port]
-v d:/data:/data  # [host path]:[container path]
--name my_container 
ubuntu:16.04 bash
#<container id> <command>
Image:
ubuntu:16.04
/data(:ro)
d:/data
Port: 8888Port: 1234
my_container
Host
--interactive , -i 開啟互動模式,可以在容器裡面輸入指令。
--tty , -t 在容器裡面開啟新的terminal。
--volume , -v 將Host資料夾映射到容器裡面。
--name 幫容器取名,預設是隨機的名稱。
--publish , -p 開啟容器的port給Host。
More in https://docs.docker.com/engine/reference/commandline/run/
WARNING !!
Delete files in /data also
delete them in d:/data.
Can add :ro for read-only
-p
-v
-it
6
Docker attach
Image:
ubuntu:16.04
Main
my_container
Host
attach: Enter the main terminal of the container.
(Ctrl+D will exit and stop the container.)
exec: Execute a command in the container.
(Ctrl+D will only terminate the new process.)
attach
docker attach my_container
docker exec -it my_container
bash
detach: Ctrl + P + Q
exit: Ctrl + D
New bash
exec
exec
7
https://docs.docker.com/
Slide by Hao-Chun Chang
Example:
Connect to
remote IDE
# In local computer
ssh -N -f -L
9487:localhost:8888
remoteUser@140.112.xx.xx
# Open browser and type
localhost:9487
# Paste TOKEN
Image:
ubuntu:16.04
/data(:ro)
d:/data
Port: 8888Port: 1234
my_container
Remote
Server
-p
-v
-it
Local
Port: 9487
140.112.xx.xx
# In remote server
> docker pull python:3.6
> docker run -it -v d:/data:/data -p 8888:1234 --name my_container
python:3.6 bash
[Press Enter to display tty in docker]
root@a57272174288:/# pip3 install jupyterlab
root@a57272174288:/# jupyter lab --allow-root --ip=0.0.0.0 --port=1234
# Copy TOKEN in …:1234/?token=“TOKEN”
8
https://docs.docker.com/
Slide by Hao-Chun Chang
Save v.s. export
Do not preserve filesystem.
Bigger size.
Preserve image history.
Potentially create multiple images.
Preserve filesystem.
Smaller size.
Does not preserve image history.
Create an empty filesystem image and
import the contents of the tarball
Container
docker export my_container >
my_container.tar
cat my_container.tar |
docker import - my_container:new
docker save my_container >
my_container.tar
docker load -i my_container.tar
Ref:
https://medium.com/@sh.tsang/docker-tutorial-4-exporting-container-and-saving-image-c3a7d792cfb6
https://stackoverflow.com/questions/36925261/what-is-the-difference-between-import-and-load-in-docke 9
Slide by Hao-Chun Chang
Cheatsheet
10
Save container into images:
docker export <container name/id> >
<filename>.tar
docker commit <container name/id>
<repo>/<image name>:<tag>
Upload images to DockerHub:
docker push <container name/id>
<repo>/<image name>:<tag>
Remove:
docker rm <container name/id>
docker rmi <image name/id>
Monitor process:
docker top <container name/id>
Download images from DockerHub:
docker pull <repository>/<image name>:tag>
Run container from image:
docker run -v [host folder path]:[container folder
path] --name <container name> <image_id>
<starting command>
List images / containers:
docker images / docker ps -a
Use running containers:
docker start/stop/restart <container name/id>
docker attach <container name/id>
docker exec -it <container name/id> <command>
Slide by Hao-Chun Chang
Some other things
apt-get update before installing ubuntu packages.
Mount volumes can only be altered using docker run.
If you want to mount additional folders, you must re-create a container.
Getting started for windows:
https://docs.docker.com/docker-for-windows/
Docker documentation:
https://docs.docker.com/
For more flexibility, you can write Dockerfile to build your own docker
images.
https://docs.docker.com/engine/reference/builder/
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
11
Slide by Hao-Chun Chang

More Related Content

What's hot

6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/20146 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
Christian Beedgen
 
Docker Workshop
Docker WorkshopDocker Workshop
Docker Workshop
Ahmad Rafiee
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
Larry Cai
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014D
 
Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and A...
Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and A...Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and A...
Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and A...
Alexey Petrov
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
Ben Hall
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with Docker
Yosh de Vos
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
Ruoshi Ling
 
Docker orchestration using core os and ansible - Ansible IL 2015
Docker orchestration using core os and ansible - Ansible IL 2015Docker orchestration using core os and ansible - Ansible IL 2015
Docker orchestration using core os and ansible - Ansible IL 2015
Leonid Mirsky
 
Containerizing Web Application with Docker
Containerizing Web Application with DockerContainerizing Web Application with Docker
Containerizing Web Application with Docker
msyukor
 
Docker at Flux7
Docker at Flux7Docker at Flux7
Docker at Flux7
Aater Suleman
 
Docker & FieldAware
Docker & FieldAwareDocker & FieldAware
Docker & FieldAwareJakub Jarosz
 
Docker for Java developers at JavaLand
Docker for Java developers at JavaLandDocker for Java developers at JavaLand
Docker for Java developers at JavaLand
Johan Janssen
 
Develop and deploy haskell with docker
Develop and deploy haskell with dockerDevelop and deploy haskell with docker
Develop and deploy haskell with docker
Chris Biscardi
 
Deploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows ContainersDeploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows Containers
Ben Hall
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
dotCloud
 
Docker remote-api
Docker remote-apiDocker remote-api
Docker remote-api
Eric Ahn
 
Docker command
Docker commandDocker command
Docker command
Eric Ahn
 
Intro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and WindowsIntro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and Windows
Thomas Chacko
 
Docker intro
Docker introDocker intro
Docker intro
Timo Derstappen
 

What's hot (20)

6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/20146 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
6 Million Ways To Log In Docker - NYC Docker Meetup 12/17/2014
 
Docker Workshop
Docker WorkshopDocker Workshop
Docker Workshop
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and A...
Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and A...Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and A...
Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and A...
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with Docker
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
 
Docker orchestration using core os and ansible - Ansible IL 2015
Docker orchestration using core os and ansible - Ansible IL 2015Docker orchestration using core os and ansible - Ansible IL 2015
Docker orchestration using core os and ansible - Ansible IL 2015
 
Containerizing Web Application with Docker
Containerizing Web Application with DockerContainerizing Web Application with Docker
Containerizing Web Application with Docker
 
Docker at Flux7
Docker at Flux7Docker at Flux7
Docker at Flux7
 
Docker & FieldAware
Docker & FieldAwareDocker & FieldAware
Docker & FieldAware
 
Docker for Java developers at JavaLand
Docker for Java developers at JavaLandDocker for Java developers at JavaLand
Docker for Java developers at JavaLand
 
Develop and deploy haskell with docker
Develop and deploy haskell with dockerDevelop and deploy haskell with docker
Develop and deploy haskell with docker
 
Deploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows ContainersDeploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows Containers
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
 
Docker remote-api
Docker remote-apiDocker remote-api
Docker remote-api
 
Docker command
Docker commandDocker command
Docker command
 
Intro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and WindowsIntro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and Windows
 
Docker intro
Docker introDocker intro
Docker intro
 

Similar to Introduction to Docker

Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
Vincent De Smet
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
Thomas Tong, FRM, PMP
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Ricardo Amaro
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
Sabyrzhan Tynybayev
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
Carlo Bonamico
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
Guido Schmutz
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant Ricardo Amaro
 
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
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
Ben Hall
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
Francesco Pantano
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to dockerJim Yeh
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Development
msyukor
 
Docker security
Docker securityDocker security
Docker security
Janos Suto
 
moscmy2016: Extending Docker
moscmy2016: Extending Dockermoscmy2016: Extending Docker
moscmy2016: Extending Docker
Mohammad Fairus Khalid
 
Présentation de Docker
Présentation de DockerPrésentation de Docker
Présentation de Docker
Proto204
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
Saeed Hajizade
 
Docker practice
Docker practiceDocker practice
Docker practice
wonyong hwang
 
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
NLJUG
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
Henryk Konsek
 

Similar to Introduction to Docker (20)

Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 
Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant
 
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
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Development
 
Docker security
Docker securityDocker security
Docker security
 
moscmy2016: Extending Docker
moscmy2016: Extending Dockermoscmy2016: Extending Docker
moscmy2016: Extending Docker
 
Présentation de Docker
Présentation de DockerPrésentation de Docker
Présentation de Docker
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
 
Docker practice
Docker practiceDocker practice
Docker practice
 
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 

Recently uploaded

A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 

Recently uploaded (20)

A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 

Introduction to Docker

  • 2. Virtual Machines 2 VM Includes a full copy of an operating system, the application, necessary binaries and libraries One VM can take up tens of GBs. It can be slow to boot. https://www.docker.com/resources/what-container Slide by Hao-Chun Chang
  • 3. Why docker? 3 https://www.docker.com/resources/what-container Slide by Hao-Chun Chang When programs have multiple versions. You can create multiple containers to prevent version conflict.
  • 4. Why docker? 4 https://www.docker.com/resources/what-container Slide by Hao-Chun Chang When you want to reproduce your analysis. Or simply transfer to a new computer. You can transfer the whole container quickly. Old New computer with Docker installed Same environment
  • 5. Workflow https://docs.docker.com/ Slide by Hao-Chun Chang docker pull ubuntu:16.04 docker images docker run -it --name my_container ubuntu:16.04 bash docker start/stop my_container https://hub.docker.com/_/ubuntu docker ps -a docker attach my_container docker exec -it my_container bash Image Container docker save/load docker export/import Dockerfile docker build Download images List images List containers docker commit my_container repo_name/my_image:v1 docker push my_container repo_name/my_image:v1 5
  • 6. Docker run https://docs.docker.com/ Slide by Hao-Chun Chang docker run -it -p 8888:1234 # [host port]:[container port] -v d:/data:/data # [host path]:[container path] --name my_container ubuntu:16.04 bash #<container id> <command> Image: ubuntu:16.04 /data(:ro) d:/data Port: 8888Port: 1234 my_container Host --interactive , -i 開啟互動模式,可以在容器裡面輸入指令。 --tty , -t 在容器裡面開啟新的terminal。 --volume , -v 將Host資料夾映射到容器裡面。 --name 幫容器取名,預設是隨機的名稱。 --publish , -p 開啟容器的port給Host。 More in https://docs.docker.com/engine/reference/commandline/run/ WARNING !! Delete files in /data also delete them in d:/data. Can add :ro for read-only -p -v -it 6
  • 7. Docker attach Image: ubuntu:16.04 Main my_container Host attach: Enter the main terminal of the container. (Ctrl+D will exit and stop the container.) exec: Execute a command in the container. (Ctrl+D will only terminate the new process.) attach docker attach my_container docker exec -it my_container bash detach: Ctrl + P + Q exit: Ctrl + D New bash exec exec 7 https://docs.docker.com/ Slide by Hao-Chun Chang
  • 8. Example: Connect to remote IDE # In local computer ssh -N -f -L 9487:localhost:8888 remoteUser@140.112.xx.xx # Open browser and type localhost:9487 # Paste TOKEN Image: ubuntu:16.04 /data(:ro) d:/data Port: 8888Port: 1234 my_container Remote Server -p -v -it Local Port: 9487 140.112.xx.xx # In remote server > docker pull python:3.6 > docker run -it -v d:/data:/data -p 8888:1234 --name my_container python:3.6 bash [Press Enter to display tty in docker] root@a57272174288:/# pip3 install jupyterlab root@a57272174288:/# jupyter lab --allow-root --ip=0.0.0.0 --port=1234 # Copy TOKEN in …:1234/?token=“TOKEN” 8 https://docs.docker.com/ Slide by Hao-Chun Chang
  • 9. Save v.s. export Do not preserve filesystem. Bigger size. Preserve image history. Potentially create multiple images. Preserve filesystem. Smaller size. Does not preserve image history. Create an empty filesystem image and import the contents of the tarball Container docker export my_container > my_container.tar cat my_container.tar | docker import - my_container:new docker save my_container > my_container.tar docker load -i my_container.tar Ref: https://medium.com/@sh.tsang/docker-tutorial-4-exporting-container-and-saving-image-c3a7d792cfb6 https://stackoverflow.com/questions/36925261/what-is-the-difference-between-import-and-load-in-docke 9 Slide by Hao-Chun Chang
  • 10. Cheatsheet 10 Save container into images: docker export <container name/id> > <filename>.tar docker commit <container name/id> <repo>/<image name>:<tag> Upload images to DockerHub: docker push <container name/id> <repo>/<image name>:<tag> Remove: docker rm <container name/id> docker rmi <image name/id> Monitor process: docker top <container name/id> Download images from DockerHub: docker pull <repository>/<image name>:tag> Run container from image: docker run -v [host folder path]:[container folder path] --name <container name> <image_id> <starting command> List images / containers: docker images / docker ps -a Use running containers: docker start/stop/restart <container name/id> docker attach <container name/id> docker exec -it <container name/id> <command> Slide by Hao-Chun Chang
  • 11. Some other things apt-get update before installing ubuntu packages. Mount volumes can only be altered using docker run. If you want to mount additional folders, you must re-create a container. Getting started for windows: https://docs.docker.com/docker-for-windows/ Docker documentation: https://docs.docker.com/ For more flexibility, you can write Dockerfile to build your own docker images. https://docs.docker.com/engine/reference/builder/ https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ 11 Slide by Hao-Chun Chang