SlideShare une entreprise Scribd logo
1  sur  15
@
Dockerfile Basics
Docker workshop #2 at @Twitter, beginners class
#dockerworkshop
Docker version 0.6.5

By Julien Barbier

@julienbarbier42
42h

Dockerfiles
• Dockerfiles = image representations
• Simple syntax for building images
• Automate and script the images creation
42h

FROM
• Sets the base image for subsequent instructions
• Usage: FROM <image>
• Example: FROM ubuntu
• Needs to be the first instruction of every Dockerfile

• TIP: find images with the command: docker search
42h

RUN
• Executes any commands on the current image and commit the
results
• Usage: RUN <command>
• Example: RUN apt-get install –y memcached
FROM ubuntu
RUN apt-get install -y memcached
is equivalent to:
$ docker run ubuntu apt-get install -y memcached
$ docker commit XXX
42h

docker build
Creates an image from a Dockerfile
• From the current directory
• From stdin
• From GitHub

$ docker build .

$ docker build - < Dockerfile
$ docker build github.com/creack/docker-firefox

TIP: Use –t to tag your image
42h

Example: Memcached
FROM ubuntu
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main
universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y memcached

• Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_6/Dockerfile
$ docker build –t memcached_d1 .
• Test it
$ docker run -i -t memcached_d1 /bin/bash
root@1f452c9442fb:/# memcached -u daemon -vvv
42h

#Commenting
• #
• Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_7/Dockerfile

# Memcached
#
# VERSION 1.0
# use the ubuntu base image provided by Docker
FROM ubuntu
# make sure the package repository is up to date
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
# install memcached
RUN apt-get install -y memcached
42h

MAINTAINER
• specify name / contact of the person maintaining the Dockerfile
• Example: MAINTAINER Julien, julien@docker.com
• Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_8/Dockerfile
# Memcached
#
# VERSION

1.0

# use the ubuntu base image provided by Docker

FROM ubuntu
MAINTAINER Julien, julien@docker.com
# make sure the package repository is up to date
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
# install memcached
RUN apt-get install -y memcached
42h

ENTRYPOINT 1/2
• Triggers a command as soon as the container starts
• Example: ENTRYPOINT echo “Whale You Be My Container?”
• Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_9/Dockerfile
# Whale you be my container?
#
# VERSION
0.42
# use the base image provided by Docker
FROM base
MAINTAINER Moby Dock victor.coisne@docker.com
# say hello when the container is launched
ENTRYPOINT echo "Whale you be my container"
42h

ENTRYPOINT 2/2
• Run containers as executables! :)
$ cat /etc/passwd | docker run -i wc

• Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_10/Dockerfile
# This is wc
#
# VERSION 0.42
# use the base image provided by Docker
FROM base
MAINTAINER Roberto roberto@docker.com
# count lines with wc
ENTRYPOINT ["wc", "-l"]
42h

USER
• Sets the username to use when running the image
• Example: USER daemon
42h

EXPOSE
• Sets ports to be exposed to other containers when running the
image (cf lightning talk by Michael Crosby @crosbymichael)
• Example: EXPOSE 80
Exercice: create a perfect Memcached
Dockerfile
Answer https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/memcached/Dockerfile
$ docker build -t memcached .
$ docker run –p 11211 memcached
#BOOM
• Try it (update port number, $ docker ps)
Python https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/memcached/test.py
Ruby https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/memcached/test.rb
PHP https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/memcached/test.php

42h
42h

Quizz: Online Dockerfile Tutorials
Test your skills here:

http://www.docker.io/learn/dockerfile/
42h

Thank you!

www.docker.io

Contenu connexe

Tendances

Docker workshop
Docker workshopDocker workshop
Docker workshop
Evans Ye
 
OpenStack - Docker - Rackspace HQ
OpenStack - Docker - Rackspace HQOpenStack - Docker - Rackspace HQ
OpenStack - Docker - Rackspace HQ
dotCloud
 

Tendances (17)

Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Austin - Container Days - Docker 101
Austin - Container Days - Docker 101Austin - Container Days - Docker 101
Austin - Container Days - Docker 101
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
 
Docker Continuous Delivery Workshop
Docker Continuous Delivery WorkshopDocker Continuous Delivery Workshop
Docker Continuous Delivery Workshop
 
Dockerizing your applications - Docker workshop @Twitter
Dockerizing your applications - Docker workshop @TwitterDockerizing your applications - Docker workshop @Twitter
Dockerizing your applications - Docker workshop @Twitter
 
OpenStack - Docker - Rackspace HQ
OpenStack - Docker - Rackspace HQOpenStack - Docker - Rackspace HQ
OpenStack - Docker - Rackspace HQ
 
Vagrant and docker
Vagrant and dockerVagrant and docker
Vagrant and docker
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
 
Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]Vagrant + Docker provider [+Puppet]
Vagrant + Docker provider [+Puppet]
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
Locally it worked! virtualizing docker
Locally it worked! virtualizing dockerLocally it worked! virtualizing docker
Locally it worked! virtualizing docker
 
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
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
Amazon Web Services and Docker
Amazon Web Services and DockerAmazon Web Services and Docker
Amazon Web Services and Docker
 
Docker Basic Presentation
Docker Basic PresentationDocker Basic Presentation
Docker Basic Presentation
 
Docker by Example - Quiz
Docker by Example - QuizDocker by Example - Quiz
Docker by Example - Quiz
 

En vedette

component based softwrae engineering Cbse
component based softwrae engineering Cbsecomponent based softwrae engineering Cbse
component based softwrae engineering Cbse
Sravs Dals
 

En vedette (20)

Docker and Sitecore : Sci-Fi or match made in heaven?
Docker and Sitecore : Sci-Fi or match made in heaven?Docker and Sitecore : Sci-Fi or match made in heaven?
Docker and Sitecore : Sci-Fi or match made in heaven?
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 
Docker - Automatisches Deployment für Linux-Instanzen
Docker - Automatisches Deployment für Linux-Instanzen Docker - Automatisches Deployment für Linux-Instanzen
Docker - Automatisches Deployment für Linux-Instanzen
 
Docker use dockerfile
Docker use dockerfileDocker use dockerfile
Docker use dockerfile
 
Vagrant, Puppet, Docker für Entwickler und Architekten
Vagrant, Puppet, Docker für Entwickler und ArchitektenVagrant, Puppet, Docker für Entwickler und Architekten
Vagrant, Puppet, Docker für Entwickler und Architekten
 
Docker, how to use it. Organize a meeting with IBM products
Docker, how to use it. Organize a meeting with IBM productsDocker, how to use it. Organize a meeting with IBM products
Docker, how to use it. Organize a meeting with IBM products
 
Talk on PHP Day Uruguay about Docker
Talk on PHP Day Uruguay about DockerTalk on PHP Day Uruguay about Docker
Talk on PHP Day Uruguay about Docker
 
Docker compose selenium-grid_tottoruby_25
Docker compose selenium-grid_tottoruby_25Docker compose selenium-grid_tottoruby_25
Docker compose selenium-grid_tottoruby_25
 
Docker - Containervirtualisierung leichtgemacht
Docker - Containervirtualisierung leichtgemachtDocker - Containervirtualisierung leichtgemacht
Docker - Containervirtualisierung leichtgemacht
 
Docker from basics to orchestration (PHPConfBr2015)
Docker from basics to orchestration (PHPConfBr2015)Docker from basics to orchestration (PHPConfBr2015)
Docker from basics to orchestration (PHPConfBr2015)
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Red Hat Certified engineer course
  Red Hat Certified engineer course   Red Hat Certified engineer course
Red Hat Certified engineer course
 
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth RushgroveThe Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
 
component based softwrae engineering Cbse
component based softwrae engineering Cbsecomponent based softwrae engineering Cbse
component based softwrae engineering Cbse
 
Docker for Developers - PNWPHP 2016 Workshop
Docker for Developers - PNWPHP 2016 WorkshopDocker for Developers - PNWPHP 2016 Workshop
Docker for Developers - PNWPHP 2016 Workshop
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Docker & PHP - Practical use case
Docker & PHP - Practical use caseDocker & PHP - Practical use case
Docker & PHP - Practical use case
 
Especialidade de inclusão 5
Especialidade de inclusão 5Especialidade de inclusão 5
Especialidade de inclusão 5
 

Similaire à Dockerfile Basics | Docker workshop #2 at twitter, 2013-11-05

Dockerfile at Guidewire
Dockerfile at GuidewireDockerfile at Guidewire
Dockerfile at Guidewire
Docker, Inc.
 
Hooking Docker With Selenium
Hooking Docker With SeleniumHooking Docker With Selenium
Hooking Docker With Selenium
Sujith Vakathanam
 
Victor Vieux at Docker Paris Meetup #1
Victor Vieux at Docker Paris Meetup #1Victor Vieux at Docker Paris Meetup #1
Victor Vieux at Docker Paris Meetup #1
Docker, Inc.
 

Similaire à Dockerfile Basics | Docker workshop #2 at twitter, 2013-11-05 (20)

Dockerfile at Guidewire
Dockerfile at GuidewireDockerfile at Guidewire
Dockerfile at Guidewire
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
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
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Django and Docker
Django and DockerDjango and Docker
Django and Docker
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken Cochrane
 
Containers #101 : Docker ONBUILD triggers and Introduction to Docker Compose
Containers #101 : Docker ONBUILD triggers and Introduction to Docker ComposeContainers #101 : Docker ONBUILD triggers and Introduction to Docker Compose
Containers #101 : Docker ONBUILD triggers and Introduction to Docker Compose
 
Introduction To Docker
Introduction To DockerIntroduction To Docker
Introduction To Docker
 
dockerizing web application
dockerizing web applicationdockerizing web application
dockerizing web application
 
Docker
DockerDocker
Docker
 
Hooking Docker With Selenium
Hooking Docker With SeleniumHooking Docker With Selenium
Hooking Docker With Selenium
 
Docker on azure
Docker on azureDocker on azure
Docker on azure
 
Docker presentation | Paris Docker Meetup
Docker presentation | Paris Docker MeetupDocker presentation | Paris Docker Meetup
Docker presentation | Paris Docker Meetup
 
Victor Vieux at Docker Paris Meetup #1
Victor Vieux at Docker Paris Meetup #1Victor Vieux at Docker Paris Meetup #1
Victor Vieux at Docker Paris Meetup #1
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 
Virtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesVirtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management services
 
Docker - Getting Started
Docker - Getting StartedDocker - Getting Started
Docker - Getting Started
 
Containers #101 Meetup: Building a micro-service using Node.js and Docker - P...
Containers #101 Meetup: Building a micro-service using Node.js and Docker - P...Containers #101 Meetup: Building a micro-service using Node.js and Docker - P...
Containers #101 Meetup: Building a micro-service using Node.js and Docker - P...
 

Plus de dotCloud

Docker in pratice -chenyifei
Docker in pratice -chenyifeiDocker in pratice -chenyifei
Docker in pratice -chenyifei
dotCloud
 
Wot2013云计算架构师峰会 -陈轶飞2
Wot2013云计算架构师峰会 -陈轶飞2Wot2013云计算架构师峰会 -陈轶飞2
Wot2013云计算架构师峰会 -陈轶飞2
dotCloud
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
dotCloud
 
Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013
dotCloud
 

Plus de dotCloud (20)

Immutable infrastructure with Docker and EC2
Immutable infrastructure with Docker and EC2Immutable infrastructure with Docker and EC2
Immutable infrastructure with Docker and EC2
 
Docker at Spotify - Dockercon14
Docker at Spotify - Dockercon14Docker at Spotify - Dockercon14
Docker at Spotify - Dockercon14
 
John Engates Keynote at Dockercon 14
John Engates Keynote at Dockercon 14John Engates Keynote at Dockercon 14
John Engates Keynote at Dockercon 14
 
Building a smarter application Stack by Tomas Doran from Yelp
Building a smarter application Stack by Tomas Doran from YelpBuilding a smarter application Stack by Tomas Doran from Yelp
Building a smarter application Stack by Tomas Doran from Yelp
 
DockerCon Keynote Ben Golub
DockerCon Keynote Ben GolubDockerCon Keynote Ben Golub
DockerCon Keynote Ben Golub
 
Are VM Passé?
Are VM Passé? Are VM Passé?
Are VM Passé?
 
Docker in pratice -chenyifei
Docker in pratice -chenyifeiDocker in pratice -chenyifei
Docker in pratice -chenyifei
 
Wot2013云计算架构师峰会 -陈轶飞2
Wot2013云计算架构师峰会 -陈轶飞2Wot2013云计算架构师峰会 -陈轶飞2
Wot2013云计算架构师峰会 -陈轶飞2
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
 
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQIntroduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
 
Dockerizing stashboard - Docker meetup at Twilio
Dockerizing stashboard - Docker meetup at TwilioDockerizing stashboard - Docker meetup at Twilio
Dockerizing stashboard - Docker meetup at Twilio
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
 
Introduction to Docker - Docker workshop @Twitter
Introduction to Docker - Docker workshop @TwitterIntroduction to Docker - Docker workshop @Twitter
Introduction to Docker - Docker workshop @Twitter
 
Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registry
 
Docker links | Docker workshop #2 at Twitter
Docker links | Docker workshop #2 at TwitterDocker links | Docker workshop #2 at Twitter
Docker links | Docker workshop #2 at Twitter
 
Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013
 
[Open stack] heat + docker
[Open stack] heat + docker[Open stack] heat + docker
[Open stack] heat + docker
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
 
Building images from dockerfiles
Building images from dockerfilesBuilding images from dockerfiles
Building images from dockerfiles
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Dockerfile Basics | Docker workshop #2 at twitter, 2013-11-05

  • 1. @ Dockerfile Basics Docker workshop #2 at @Twitter, beginners class #dockerworkshop Docker version 0.6.5 By Julien Barbier @julienbarbier42
  • 2. 42h Dockerfiles • Dockerfiles = image representations • Simple syntax for building images • Automate and script the images creation
  • 3. 42h FROM • Sets the base image for subsequent instructions • Usage: FROM <image> • Example: FROM ubuntu • Needs to be the first instruction of every Dockerfile • TIP: find images with the command: docker search
  • 4. 42h RUN • Executes any commands on the current image and commit the results • Usage: RUN <command> • Example: RUN apt-get install –y memcached FROM ubuntu RUN apt-get install -y memcached is equivalent to: $ docker run ubuntu apt-get install -y memcached $ docker commit XXX
  • 5. 42h docker build Creates an image from a Dockerfile • From the current directory • From stdin • From GitHub $ docker build . $ docker build - < Dockerfile $ docker build github.com/creack/docker-firefox TIP: Use –t to tag your image
  • 6. 42h Example: Memcached FROM ubuntu RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get install -y memcached • Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_6/Dockerfile $ docker build –t memcached_d1 . • Test it $ docker run -i -t memcached_d1 /bin/bash root@1f452c9442fb:/# memcached -u daemon -vvv
  • 7. 42h #Commenting • # • Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_7/Dockerfile # Memcached # # VERSION 1.0 # use the ubuntu base image provided by Docker FROM ubuntu # make sure the package repository is up to date RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update # install memcached RUN apt-get install -y memcached
  • 8. 42h MAINTAINER • specify name / contact of the person maintaining the Dockerfile • Example: MAINTAINER Julien, julien@docker.com • Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_8/Dockerfile # Memcached # # VERSION 1.0 # use the ubuntu base image provided by Docker FROM ubuntu MAINTAINER Julien, julien@docker.com # make sure the package repository is up to date RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update # install memcached RUN apt-get install -y memcached
  • 9. 42h ENTRYPOINT 1/2 • Triggers a command as soon as the container starts • Example: ENTRYPOINT echo “Whale You Be My Container?” • Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_9/Dockerfile # Whale you be my container? # # VERSION 0.42 # use the base image provided by Docker FROM base MAINTAINER Moby Dock victor.coisne@docker.com # say hello when the container is launched ENTRYPOINT echo "Whale you be my container"
  • 10. 42h ENTRYPOINT 2/2 • Run containers as executables! :) $ cat /etc/passwd | docker run -i wc • Dockerfile: https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/slide_10/Dockerfile # This is wc # # VERSION 0.42 # use the base image provided by Docker FROM base MAINTAINER Roberto roberto@docker.com # count lines with wc ENTRYPOINT ["wc", "-l"]
  • 11. 42h USER • Sets the username to use when running the image • Example: USER daemon
  • 12. 42h EXPOSE • Sets ports to be exposed to other containers when running the image (cf lightning talk by Michael Crosby @crosbymichael) • Example: EXPOSE 80
  • 13. Exercice: create a perfect Memcached Dockerfile Answer https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/memcached/Dockerfile $ docker build -t memcached . $ docker run –p 11211 memcached #BOOM • Try it (update port number, $ docker ps) Python https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/memcached/test.py Ruby https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/memcached/test.rb PHP https://github.com/jbarbier/Dockerfile-Basics-Docker-Workshop-2-Twitter/blob/master/memcached/test.php 42h
  • 14. 42h Quizz: Online Dockerfile Tutorials Test your skills here: http://www.docker.io/learn/dockerfile/