SlideShare a Scribd company logo
Developing in Docker
YipitData is not endorsed by, directly affiliated with, maintained,
authorized, or sponsored by Docker Inc.
Disclaimer
Getting Started with Docker
● Brief terminology
● Running containers
● Dockerfiles & Images
● Tips for development
General Outline
● Dockerfile: Defines the instructions to create an image
● Image: An executable package that contains the resources
needed to run a container
● Container: The result (a process) of executing an image. A
new container is made each time an image is executed
Dockerfile, Images, Containers, .. ?
● An easy way to create a container is by using “docker run”
docker run -it --rm <IMAGE:TAG> <COMMAND>
● Example:
docker run -it --rm python:3.6.5-jessie python
OK, but how do I even container ?
● An easy way to create a container is by using “docker run”
docker run -it --rm <IMAGE:TAG> <COMMAND>
OK, but how do I even container ?
Exposes STDIN to the container and
emulates a terminal session. It lets you run
commands within the container
● An easy way to create a container is by using “docker run”
docker run -it --rm <IMAGE:TAG> <COMMAND>
OK, but how do I even container ?
Deletes the container after you exit
the process, helps keep disk space
under control
● There is no concept of “SSH” in docker. But you can access a
shell in a running container using docker exec:
docker exec -it <CONTAINER ID> bash
● You can find the container ID by running:
docker ps
So what about SSH ..
Live Demo
Exec into a container
● Exec is helpful during development to debug a container’s state
● When debugging production, you should try to recreate the
error using a fresh container locally
○ Exec is not supported in production
○ “Show Docker CLI” in YAWS is your friend
○ Enable logging to see more details
Don’t exec unless you have to.
Getting Started with Docker
Check out this sweet Dockerfile ..
FROM python:3.6.7-jessie
COPY app /app
RUN pip install Flask
EXPOSE 8000
CMD ["python", "/app/__init__.py"]
FROM python:3.6.7-jessie
COPY app /app
RUN pip install Flask
EXPOSE 8000
CMD ["python", "/app/__init__.py"]
Check out this sweet Dockerfile ..
FROM loads a published
image as a starting point for
your application
FROM python:3.6.7-jessie
COPY app /app
RUN pip install Flask
EXPOSE 8000
CMD ["python", "/app/__init__.py"]
Check out this sweet Dockerfile ..
COPY takes files in the host file system
and moves them into the image
FROM python:3.6.7-jessie
COPY app /app
RUN pip install Flask
EXPOSE 8000
CMD ["python", "/app/__init__.py"]
Check out this sweet Dockerfile ..
RUN allows you to execute
commands inside the image
EXPOSE defines a
port that can be
accessed outside of
the container
FROM python:3.6.7-jessie
COPY app /app
RUN pip install Flask
EXPOSE 8000
CMD ["python", "/app/__init__.py"]
Check out this sweet Dockerfile ..
FROM python:3.6.7-jessie
COPY app /app
RUN pip install Flask
EXPOSE 8000
CMD ["python", "/app/__init__.py"]
Check out this sweet Dockerfile ..
CMD defines a
default command
the container will
run
docker build -t <NAME>:<TAG> <PATH>
“docker build” translates a Dockerfile into an image
docker build -t <NAME>:<TAG> <PATH>
Important to tag a readable
name for your image
“docker build” translates a Dockerfile into an image
docker build -t <NAME>:<TAG> <PATH>
Specifying a version will pin
changes of the images you
create
“docker build” translates a Dockerfile into an image
docker build -t <NAME>:<TAG> <PATH>
Path to your Dockerfile
and application code
“docker build” translates a Dockerfile into an image
● Each instruction is a
layer, a change in the
image state
● Only FROM, RUN, and
COPY create layers
● The R/W layer is created
when running a container
An image is a series of “layers”
● Ephemeral: Containers are created / destroyed with ease, and
any setup is handled by the image
● Few in Layers: More layers lead to larger image size and longer
build time
● Ordered for caching: The instructions in the Dockerfile are
sequenced to leverage caching. Least likely to change or
longest running instructions should be higher up
The best Dockerfiles are:
Live Demo
Caching in action
● Base images can have unnecessary packages installed that
inflate your image size
FROM python:3.6.7-slim-jessie (157 MB)
FROM python:3.6.7-jessie (691 MB)
● Use a versioned base image, or your image will be built on the
latest base image (unstable)
Use the right base image
● A common technique is to chain shell commands using the &&
operator
RUN apt-get update
RUN apt-get install -y cron
vs.
RUN apt-get update 
&& apt-get install -y cron
Combine layers as much as possible
● Linux by default will install many “recommended” packages you
do not need. You can disable this behavior:
RUN apt-get update 
&& apt-get install -y --no-install-recommends 
cron
Install only what you need
● Packages may have extraneous files once installed, best
practice is to remove them
RUN curl s3://yipit/my_pkg.deb > my_pkg.deb 
&& dpkg -i my_pkg.deb 
&& rm -rf my_pkg.deb
Delete temporary files after installation
● The demo images were small to begin with, production image
sizes can decrease 60 - 70%
Significant reductions in image size
Absolute file path in the host
machine you want to mount
● Volumes mount external (host) files to a container
● You can continue to modify these files and your running
container will be up to date
docker run --rm -it -v <HOST PATH:CONTAINER PATH> 
<IMAGE:TAG>
Use volumes to speed up app development
● Volumes mount external (host) files to a container
● You can continue to modify these files and your running
container will be up to date
docker run --rm -it -v <HOST PATH:CONTAINER PATH> 
<IMAGE:TAG>
Destination file path in the
container for the mounted file(s)
Use volumes to speed up app development
Live Demo
Using volumes
● Two ways to set variables in the Dockerfile, ARG and ENV
● ARG defines a build-time variable that is out of scope once the
image is built
○ Good for secrets only used in setup (ex: localshop)
● ENV sets an environment variable that is in scope during and
after the image is built
Environment variables
● Both variables can be set via the CLI. They will override values
in the Dockerfile
● ARG:
docker build --build-arg <NAME=VALUE> -t
<IMAGE:TAG> .
● ENV:
docker run --rm -it -e <NAME=VALUE> <IMAGE:TAG>
Environment variables in the CLI
● You will want to end your Dockerfile with a CMD and/or
ENTRYPOINT (or inherit from your base image)
● An ENTRYPOINT executes code right at a container’s runtime
○ Establish background processes / services
○ Wrap additional context around commands
○ A CMD is passed as an argument to the entrypoint
CMD or ENTRYPOINT?
Live Demo
Entrypoint
● Docker is a large platform and there is so much more to learn
● Best ways to get started:
○ Documentation: https://docs.docker.com/
○ Read Dockerfiles for base images (usually on github)
○ Build some images!
Tip of the iceberg ..
● Containers improves parity of local development to production
○ The image you build is the image you deploy
○ Far easier to reproduce bugs
● Increases flexibility in your application architecture
○ OS packages easier to manage (no need for brew or chef)
○ Python versioning is simplified (no virtualenv)
But it pays off !
Questions?
● Official Docker Documentation
● Best Practices for Writing Dockerfiles
● Docker Container Layers
● XKCD on Containers
● XKCD on Compiling
References
Ad

More Related Content

What's hot (20)

Vagrant and docker
Vagrant and dockerVagrant and docker
Vagrant and docker
DuckDuckGo
 
Docker orchestration
Docker orchestrationDocker orchestration
Docker orchestration
Open Source Consulting
 
Docker at Monoco.jp (LinkedIn)
Docker at Monoco.jp (LinkedIn)Docker at Monoco.jp (LinkedIn)
Docker at Monoco.jp (LinkedIn)
Akhmad Fathonih
 
Deployment Automation with Docker
Deployment Automation with DockerDeployment Automation with Docker
Deployment Automation with Docker
Egor Pushkin
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java bin
Olve Hansen
 
Vagrant to-aws-flow
Vagrant to-aws-flowVagrant to-aws-flow
Vagrant to-aws-flow
Kimberly Macias
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Kuan Yen Heng
 
Vagrant
VagrantVagrant
Vagrant
Michael Peacock
 
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3 Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best Practices
Docker, Inc.
 
Provisioning & Deploying with Docker
Provisioning & Deploying with DockerProvisioning & Deploying with Docker
Provisioning & Deploying with Docker
Erica Windisch
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
Justin Crown
 
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
 
Automating Docker Containers with Puppet 2014 10-13
Automating Docker Containers with Puppet 2014 10-13Automating Docker Containers with Puppet 2014 10-13
Automating Docker Containers with Puppet 2014 10-13
kylog
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and Docker
Daniel Ku
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGHDeploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Erica Windisch
 
Austin - Container Days - Docker 101
Austin - Container Days - Docker 101Austin - Container Days - Docker 101
Austin - Container Days - Docker 101
Bill Maxwell
 
Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for Jenkins
Larry Cai
 
Using docker to develop NAS applications
Using docker to develop NAS applicationsUsing docker to develop NAS applications
Using docker to develop NAS applications
Terry Chen
 
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
 
Vagrant and docker
Vagrant and dockerVagrant and docker
Vagrant and docker
DuckDuckGo
 
Docker at Monoco.jp (LinkedIn)
Docker at Monoco.jp (LinkedIn)Docker at Monoco.jp (LinkedIn)
Docker at Monoco.jp (LinkedIn)
Akhmad Fathonih
 
Deployment Automation with Docker
Deployment Automation with DockerDeployment Automation with Docker
Deployment Automation with Docker
Egor Pushkin
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java bin
Olve Hansen
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Kuan Yen Heng
 
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3 Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best Practices
Docker, Inc.
 
Provisioning & Deploying with Docker
Provisioning & Deploying with DockerProvisioning & Deploying with Docker
Provisioning & Deploying with Docker
Erica Windisch
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
Justin Crown
 
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
 
Automating Docker Containers with Puppet 2014 10-13
Automating Docker Containers with Puppet 2014 10-13Automating Docker Containers with Puppet 2014 10-13
Automating Docker Containers with Puppet 2014 10-13
kylog
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and Docker
Daniel Ku
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGHDeploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Erica Windisch
 
Austin - Container Days - Docker 101
Austin - Container Days - Docker 101Austin - Container Days - Docker 101
Austin - Container Days - Docker 101
Bill Maxwell
 
Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for Jenkins
Larry Cai
 
Using docker to develop NAS applications
Using docker to develop NAS applicationsUsing docker to develop NAS applications
Using docker to develop NAS applications
Terry Chen
 
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
 

Similar to Getting Started with Docker (20)

IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
Eric Smalling
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
Thomas Tong, FRM, PMP
 
Deliver Python Apps with Docker
Deliver Python Apps with DockerDeliver Python Apps with Docker
Deliver Python Apps with Docker
Anton Egorov
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
Binary Studio
 
Docker in a JS Developer’s Life
Docker in a JS Developer’s LifeDocker in a JS Developer’s Life
Docker in a JS Developer’s Life
GlobalLogic Ukraine
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline
Docker, Inc.
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
Alper Kanat
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
OKLABS
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
Naukri.com
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
Alexandre Salomé
 
Computer science docker file Week -6 to7
Computer science docker file Week -6 to7Computer science docker file Week -6 to7
Computer science docker file Week -6 to7
jemy24r
 
Docker basics 30_01_21.ppx
Docker basics 30_01_21.ppxDocker basics 30_01_21.ppx
Docker basics 30_01_21.ppx
Panuwat Boonrod
 
How to write a Dockerfile
How to write a DockerfileHow to write a Dockerfile
How to write a Dockerfile
Knoldus Inc.
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with Gitlab
Ayush Sharma
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
Samuel Chow
 
Introduction to Docker for NodeJs developers at Node DC 2/26/2014
Introduction to Docker for NodeJs developers at Node DC 2/26/2014Introduction to Docker for NodeJs developers at Node DC 2/26/2014
Introduction to Docker for NodeJs developers at Node DC 2/26/2014
lenworthhenry
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
Hannes Hapke
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
Troublemaker Khunpech
 
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
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
Eric Smalling
 
Deliver Python Apps with Docker
Deliver Python Apps with DockerDeliver Python Apps with Docker
Deliver Python Apps with Docker
Anton Egorov
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
Binary Studio
 
Docker in a JS Developer’s Life
Docker in a JS Developer’s LifeDocker in a JS Developer’s Life
Docker in a JS Developer’s Life
GlobalLogic Ukraine
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline
Docker, Inc.
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
Alper Kanat
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
OKLABS
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
Naukri.com
 
Computer science docker file Week -6 to7
Computer science docker file Week -6 to7Computer science docker file Week -6 to7
Computer science docker file Week -6 to7
jemy24r
 
Docker basics 30_01_21.ppx
Docker basics 30_01_21.ppxDocker basics 30_01_21.ppx
Docker basics 30_01_21.ppx
Panuwat Boonrod
 
How to write a Dockerfile
How to write a DockerfileHow to write a Dockerfile
How to write a Dockerfile
Knoldus Inc.
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with Gitlab
Ayush Sharma
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
Samuel Chow
 
Introduction to Docker for NodeJs developers at Node DC 2/26/2014
Introduction to Docker for NodeJs developers at Node DC 2/26/2014Introduction to Docker for NodeJs developers at Node DC 2/26/2014
Introduction to Docker for NodeJs developers at Node DC 2/26/2014
lenworthhenry
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
Hannes Hapke
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
Troublemaker Khunpech
 
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
 
Ad

Recently uploaded (20)

What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Ad

Getting Started with Docker

  • 2. YipitData is not endorsed by, directly affiliated with, maintained, authorized, or sponsored by Docker Inc. Disclaimer
  • 4. ● Brief terminology ● Running containers ● Dockerfiles & Images ● Tips for development General Outline
  • 5. ● Dockerfile: Defines the instructions to create an image ● Image: An executable package that contains the resources needed to run a container ● Container: The result (a process) of executing an image. A new container is made each time an image is executed Dockerfile, Images, Containers, .. ?
  • 6. ● An easy way to create a container is by using “docker run” docker run -it --rm <IMAGE:TAG> <COMMAND> ● Example: docker run -it --rm python:3.6.5-jessie python OK, but how do I even container ?
  • 7. ● An easy way to create a container is by using “docker run” docker run -it --rm <IMAGE:TAG> <COMMAND> OK, but how do I even container ? Exposes STDIN to the container and emulates a terminal session. It lets you run commands within the container
  • 8. ● An easy way to create a container is by using “docker run” docker run -it --rm <IMAGE:TAG> <COMMAND> OK, but how do I even container ? Deletes the container after you exit the process, helps keep disk space under control
  • 9. ● There is no concept of “SSH” in docker. But you can access a shell in a running container using docker exec: docker exec -it <CONTAINER ID> bash ● You can find the container ID by running: docker ps So what about SSH ..
  • 10. Live Demo Exec into a container
  • 11. ● Exec is helpful during development to debug a container’s state ● When debugging production, you should try to recreate the error using a fresh container locally ○ Exec is not supported in production ○ “Show Docker CLI” in YAWS is your friend ○ Enable logging to see more details Don’t exec unless you have to.
  • 13. Check out this sweet Dockerfile .. FROM python:3.6.7-jessie COPY app /app RUN pip install Flask EXPOSE 8000 CMD ["python", "/app/__init__.py"]
  • 14. FROM python:3.6.7-jessie COPY app /app RUN pip install Flask EXPOSE 8000 CMD ["python", "/app/__init__.py"] Check out this sweet Dockerfile .. FROM loads a published image as a starting point for your application
  • 15. FROM python:3.6.7-jessie COPY app /app RUN pip install Flask EXPOSE 8000 CMD ["python", "/app/__init__.py"] Check out this sweet Dockerfile .. COPY takes files in the host file system and moves them into the image
  • 16. FROM python:3.6.7-jessie COPY app /app RUN pip install Flask EXPOSE 8000 CMD ["python", "/app/__init__.py"] Check out this sweet Dockerfile .. RUN allows you to execute commands inside the image
  • 17. EXPOSE defines a port that can be accessed outside of the container FROM python:3.6.7-jessie COPY app /app RUN pip install Flask EXPOSE 8000 CMD ["python", "/app/__init__.py"] Check out this sweet Dockerfile ..
  • 18. FROM python:3.6.7-jessie COPY app /app RUN pip install Flask EXPOSE 8000 CMD ["python", "/app/__init__.py"] Check out this sweet Dockerfile .. CMD defines a default command the container will run
  • 19. docker build -t <NAME>:<TAG> <PATH> “docker build” translates a Dockerfile into an image
  • 20. docker build -t <NAME>:<TAG> <PATH> Important to tag a readable name for your image “docker build” translates a Dockerfile into an image
  • 21. docker build -t <NAME>:<TAG> <PATH> Specifying a version will pin changes of the images you create “docker build” translates a Dockerfile into an image
  • 22. docker build -t <NAME>:<TAG> <PATH> Path to your Dockerfile and application code “docker build” translates a Dockerfile into an image
  • 23. ● Each instruction is a layer, a change in the image state ● Only FROM, RUN, and COPY create layers ● The R/W layer is created when running a container An image is a series of “layers”
  • 24. ● Ephemeral: Containers are created / destroyed with ease, and any setup is handled by the image ● Few in Layers: More layers lead to larger image size and longer build time ● Ordered for caching: The instructions in the Dockerfile are sequenced to leverage caching. Least likely to change or longest running instructions should be higher up The best Dockerfiles are:
  • 26. ● Base images can have unnecessary packages installed that inflate your image size FROM python:3.6.7-slim-jessie (157 MB) FROM python:3.6.7-jessie (691 MB) ● Use a versioned base image, or your image will be built on the latest base image (unstable) Use the right base image
  • 27. ● A common technique is to chain shell commands using the && operator RUN apt-get update RUN apt-get install -y cron vs. RUN apt-get update && apt-get install -y cron Combine layers as much as possible
  • 28. ● Linux by default will install many “recommended” packages you do not need. You can disable this behavior: RUN apt-get update && apt-get install -y --no-install-recommends cron Install only what you need
  • 29. ● Packages may have extraneous files once installed, best practice is to remove them RUN curl s3://yipit/my_pkg.deb > my_pkg.deb && dpkg -i my_pkg.deb && rm -rf my_pkg.deb Delete temporary files after installation
  • 30. ● The demo images were small to begin with, production image sizes can decrease 60 - 70% Significant reductions in image size
  • 31. Absolute file path in the host machine you want to mount ● Volumes mount external (host) files to a container ● You can continue to modify these files and your running container will be up to date docker run --rm -it -v <HOST PATH:CONTAINER PATH> <IMAGE:TAG> Use volumes to speed up app development
  • 32. ● Volumes mount external (host) files to a container ● You can continue to modify these files and your running container will be up to date docker run --rm -it -v <HOST PATH:CONTAINER PATH> <IMAGE:TAG> Destination file path in the container for the mounted file(s) Use volumes to speed up app development
  • 34. ● Two ways to set variables in the Dockerfile, ARG and ENV ● ARG defines a build-time variable that is out of scope once the image is built ○ Good for secrets only used in setup (ex: localshop) ● ENV sets an environment variable that is in scope during and after the image is built Environment variables
  • 35. ● Both variables can be set via the CLI. They will override values in the Dockerfile ● ARG: docker build --build-arg <NAME=VALUE> -t <IMAGE:TAG> . ● ENV: docker run --rm -it -e <NAME=VALUE> <IMAGE:TAG> Environment variables in the CLI
  • 36. ● You will want to end your Dockerfile with a CMD and/or ENTRYPOINT (or inherit from your base image) ● An ENTRYPOINT executes code right at a container’s runtime ○ Establish background processes / services ○ Wrap additional context around commands ○ A CMD is passed as an argument to the entrypoint CMD or ENTRYPOINT?
  • 38. ● Docker is a large platform and there is so much more to learn ● Best ways to get started: ○ Documentation: https://docs.docker.com/ ○ Read Dockerfiles for base images (usually on github) ○ Build some images! Tip of the iceberg ..
  • 39. ● Containers improves parity of local development to production ○ The image you build is the image you deploy ○ Far easier to reproduce bugs ● Increases flexibility in your application architecture ○ OS packages easier to manage (no need for brew or chef) ○ Python versioning is simplified (no virtualenv) But it pays off !
  • 41. ● Official Docker Documentation ● Best Practices for Writing Dockerfiles ● Docker Container Layers ● XKCD on Containers ● XKCD on Compiling References