SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
DockerCompose
Explained
- A simple command to start a container
- options are available through command line parameters
- options specified here are:
- d -- detached
- i -- interactive
- t -- assign a tty
- --name -- assigns a name to the running image
- these options may sound contradictory, the result leaves a
running image
- there's a point where rerunning with all the options does get
cumbersome
- at this point a shell script is a viable solution
dockerisgoodforonecontainer
docker run 
-dit 
--name metacpan-api 
metacpan-api:latest 
/bin/bash
- Two containers isn't too bad to
manage
- running both from the shell with
an && to ensure proper starting
order
- same caveat, lots of options
could require a shell script
ortwocontainers
docker run -d 
--name metacpan-pgdb 
metacpan-pgdb:latest
&&
docker run -d 
--name metacpan-api 
metacpan-api:latest
- metacpan has 5 different containers
- 2 elasticsearch
- 1 postgresql
- 1 api
- 1 web
- networks
- elasticsearch
- web
- database
- mounted volumes
- more than I care to count
Butwhathappenswhenyouhave5?
- Our current project has 45
different containers
- as a side note these details
can be obtained by running
docker-compose config
--services
Or45?
- Compose is a tool for defining and
running multi-container Docker
applications.
- YAML file to configure your
applicationʼs services.
- single command, you create and
start all the services from your
configuration.
Whatis
docker-compose
- this is a very simplistic model
- 2 containers, web & api
- the version number here is
significant
- the depends_on attribute
automatically starts api if we only
start web
Simple docker-compose.yml
version: "3.4"
services:
web:
image: metacpan-web:lastest
depends_on:
- api
api:
image: metacpan-api:lastest
- version 3.0 indiciates Docker Engine relase
1.33.0+
- version 3.7 indiciates Docker Engine relase
18.06.0+
- what attributes are available to be defined varies
greatly
- healthcheck for example is only supported
from version 2.1
- while mounting volumes read-only is only
available in 3.4
A word about version numbers
· Dictates the version of docker
· Indicative of the attributes available
- A little side story
- I had intended to use reveal.js for this presentation
- the formatting and code highlighting really bugged me
- I've reverted back to using DeckSet
- but had I continue...
- this is the run command suggested for running this
presentation in a container
- there are a lot of volumes to be mounted, and rerunning
by hand is definitely not something you'd want to do
- docker image is from https://github.com/
nbrownuk/docker-revealjs
Example of docker run with many options
docker run -it --rm -p 8000:8000 
-v $PWD/index.html:/reveal.js/index.html 
-v $PWD/media:/reveal.js/media 
-v $PWD/custom.css:/reveal.js/css/theme/custom.css 
-v $PWD/menu:/reveal.js/plugin/menu 
nbrown/revealjs
Docker image is from https://github.com/
nbrownuk/docker-revealjs
- let's convert the docker run
command from the previous
slide into a working docker-
compose.yml
Exercise
- when doing a conversion I
like to keep the code that I'm
replacing local
- I comment it out and delete
the bits I'm working on and
paste them in the real code
Converting a docker run command
# docker run -it --rm -p 8000:8000 
# -v $PWD/index.html:/reveal.js/index.html 
# -v $PWD/media:/reveal.js/media 
# -v $PWD/custom.css:/reveal.js/css/theme/custom.css 
# -v $PWD/menu:/reveal.js/plugin/menu 
# nbrown/revealjs
- start off with the required bits
- specify the version of the file (I
want read-only mounts)
- start the services definitions
- name the service reveal in
this case
Converting a docker run command
# docker run -it --rm -p 8000:8000 
# -v $PWD/index.html:/reveal.js/index.html 
# -v $PWD/media:/reveal.js/media 
# -v $PWD/custom.css:/reveal.js/css/theme/custom.css 
# -v $PWD/menu:/reveal.js/plugin/menu 
# nbrown/revealjs
version: "3.4"
services:
reveal:
- we're going to define the
image
Converting a docker run command
# docker run -it --rm -p 8000:8000 
# -v $PWD/index.html:/reveal.js/index.html 
# -v $PWD/media:/reveal.js/media 
# -v $PWD/custom.css:/reveal.js/css/theme/custom.css 
# -v $PWD/menu:/reveal.js/plugin/menu 
# nbrown/revealjs
version: "3.4"
services:
reveal:
image: nbrown/revealjs:latest
- we're going to define the ports in use
- the first port is the external listening port, the
second is the internal
- this is used for when you want to access a
container from the host
- for the presentation I want to point my browser
at 127.0.0.1:8000
- while I'm removing the ports definition from the
run command, I'm going to remove the run
command
Converting a docker run command
# docker run -it --rm -p 8000:8000 
# -v $PWD/index.html:/reveal.js/index.html 
# -v $PWD/media:/reveal.js/media 
# -v $PWD/custom.css:/reveal.js/css/theme/custom.css 
# -v $PWD/menu:/reveal.js/plugin/menu
#
version: "3.4"
services:
reveal:
image: nbrown/revealjs:latest
ports:
- 8000:8000
- What I'm left with here are
the volumes
Converting a docker run command
#
# -v $PWD/index.html:/reveal.js/index.html 
# -v $PWD/media:/reveal.js/media 
# -v $PWD/custom.css:/reveal.js/css/theme/custom.css 
# -v $PWD/menu:/reveal.js/plugin/menu
#
version: "3.4"
services:
reveal:
image: nbrown/revealjs:latest
ports:
- 8000:8000
volumes:
- What I'm left with here are
the volumes
Converting a docker run command
#
# -v $PWD/index.html:/reveal.js/index.html 
# -v $PWD/media:/reveal.js/media 
# -v $PWD/custom.css:/reveal.js/css/theme/custom.css 
# -v $PWD/menu:/reveal.js/plugin/menu
#
version: "3.4"
services:
reveal:
image: nbrown/revealjs:latest
ports:
- 8000:8000
volumes:
- the first volume is for the index.html
- docker volumes are defined source:destination
on the command line
- In the docker-compose, I'm using expanded syntax as
it's easier to read and allows for more options
- type is bind, because we're specifically mounting a
file, a remote volume would be type volume
- source - while docker-compose supports environment
variables and other variables, it's not required here
- destination - this is where the application in the
container is expecting the file to be
Converting a docker run command
#
# -v $PWD/index.html:/reveal.js/index.html 
# -v $PWD/media:/reveal.js/media 
# -v $PWD/custom.css:/reveal.js/css/theme/custom.css 
# -v $PWD/menu:/reveal.js/plugin/menu
#
version: "3.4"
services:
reveal:
image: nbrown/revealjs:latest
ports:
- 8000:8000
volumes:
- type: bind
source: ./index.html
target: /reveal.js/index.html
read_only: true
Complete docker-compose.yml
version: "3.4"
services:
reveal:
image: nbrown/revealjs:latest
ports:
- 8000:8000
volumes:
- type: bind
source: ./index.html
target: /reveal.js/index.html
read_only: true
- type: bind
source: ./media
target: /reveal.js/media
read_only: true
- type: bind
source: ./custom.css
target: /reveal.js/css/theme/custom.css
read_only: true
- type: bind
source: ./menu
target: /reveal.js/plugin/menu
read_only: true
- type: bind
source: ./md
target: /reveal.js/md
read_only: true
- without the -d option docker-compose up will
start containers and logging in the foreground
- the --volumes options to docker-compose down
removes any persistent storage volumes that are defined
- useful if you can recreate your database from scratch
- log is extremely useful if you've started containers in
detached mode, it also supports -f just like tail
- docker-compose was originally called fig, which is a
lot less typing
- create an alias, save your fingers
Simple Commands
· docker-compose up
builds creates/recreates and attaches to containers
· docker-compose down
stops and removes containers, networks and volumes
· docker-compose stop
stops containers without removing them
· docker-compose start
starts existing containers for a service
· docker-compose log
starts existing containers for a service
Furtherreading
· Docker Compose documentation
https://docs.docker.com/v17.09/compose/
overview/`
END

Weitere ähnliche Inhalte

Was ist angesagt?

Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with DockerRavindu Fernando
 
Introduzione a Docker (Maggio 2017) [ITA]
Introduzione a Docker (Maggio 2017) [ITA]Introduzione a Docker (Maggio 2017) [ITA]
Introduzione a Docker (Maggio 2017) [ITA]Valerio Radice
 
Docker introduction & benefits
Docker introduction & benefitsDocker introduction & benefits
Docker introduction & benefitsAmit Manwade
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageejlp12
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersYajushi Srivastava
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionRobert Reiz
 
Midi technique - présentation docker
Midi technique - présentation dockerMidi technique - présentation docker
Midi technique - présentation dockerOlivier Eeckhoutte
 
Why Docker
Why DockerWhy Docker
Why DockerdotCloud
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An IntroductionPOSSCON
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker ComposeAjeet Singh Raina
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking OverviewSreenivas Makam
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetesDongwon Kim
 

Was ist angesagt? (20)

Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Introduzione a Docker (Maggio 2017) [ITA]
Introduzione a Docker (Maggio 2017) [ITA]Introduzione a Docker (Maggio 2017) [ITA]
Introduzione a Docker (Maggio 2017) [ITA]
 
Docker Tutorial.pdf
Docker Tutorial.pdfDocker Tutorial.pdf
Docker Tutorial.pdf
 
Docker introduction & benefits
Docker introduction & benefitsDocker introduction & benefits
Docker introduction & benefits
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Dockerfile
Dockerfile Dockerfile
Dockerfile
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Midi technique - présentation docker
Midi technique - présentation dockerMidi technique - présentation docker
Midi technique - présentation docker
 
Docker compose
Docker composeDocker compose
Docker compose
 
Why Docker
Why DockerWhy Docker
Why Docker
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An Introduction
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking Overview
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 

Ähnlich wie Docker Compose Explained

PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...Puppet
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configurationlutter
 
Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview Thomas Chacko
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Ben Hall
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nirmal Mehta
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachPROIDEA
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peekmsyukor
 
.NET Developer Days - Launching Patterns for Containers
.NET Developer Days - Launching Patterns for Containers.NET Developer Days - Launching Patterns for Containers
.NET Developer Days - Launching Patterns for ContainersMichele Leroux Bustamante
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Ben Hall
 
Docker container management
Docker container managementDocker container management
Docker container managementKarol Kreft
 
Intersog Hack_n_Tell. Docker. First steps.
Intersog Hack_n_Tell. Docker. First steps.Intersog Hack_n_Tell. Docker. First steps.
Intersog Hack_n_Tell. Docker. First steps.Intersog
 
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 2020CloudHero
 
Deploying configurable frontend web application containers
Deploying configurable frontend web application containersDeploying configurable frontend web application containers
Deploying configurable frontend web application containersJosé Moreira
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017Paul Chao
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeNicola Paolucci
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshopRuncy Oommen
 
Docker in Action
Docker in ActionDocker in Action
Docker in ActionSimon Su
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作Philip Zheng
 

Ähnlich wie Docker Compose Explained (20)

PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview Docker Distributed application bundle & Stack - Overview
Docker Distributed application bundle & Stack - Overview
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
 
.NET Developer Days - Launching Patterns for Containers
.NET Developer Days - Launching Patterns for Containers.NET Developer Days - Launching Patterns for Containers
.NET Developer Days - Launching Patterns for Containers
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Docker container management
Docker container managementDocker container management
Docker container management
 
Intersog Hack_n_Tell. Docker. First steps.
Intersog Hack_n_Tell. Docker. First steps.Intersog Hack_n_Tell. Docker. First steps.
Intersog Hack_n_Tell. Docker. First steps.
 
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
 
Deploying configurable frontend web application containers
Deploying configurable frontend web application containersDeploying configurable frontend web application containers
Deploying configurable frontend web application containers
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the trade
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
 

Kürzlich hochgeladen

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)wesley chun
 
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 2024Rafal Los
 
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 organizationRadu Cotescu
 
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...Neo4j
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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 RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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 SolutionsEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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 Processorsdebabhi2
 

Kürzlich hochgeladen (20)

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)
 
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
 
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
 
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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 

Docker Compose Explained

  • 2. - A simple command to start a container - options are available through command line parameters - options specified here are: - d -- detached - i -- interactive - t -- assign a tty - --name -- assigns a name to the running image - these options may sound contradictory, the result leaves a running image - there's a point where rerunning with all the options does get cumbersome - at this point a shell script is a viable solution dockerisgoodforonecontainer docker run -dit --name metacpan-api metacpan-api:latest /bin/bash
  • 3. - Two containers isn't too bad to manage - running both from the shell with an && to ensure proper starting order - same caveat, lots of options could require a shell script ortwocontainers docker run -d --name metacpan-pgdb metacpan-pgdb:latest && docker run -d --name metacpan-api metacpan-api:latest
  • 4. - metacpan has 5 different containers - 2 elasticsearch - 1 postgresql - 1 api - 1 web - networks - elasticsearch - web - database - mounted volumes - more than I care to count Butwhathappenswhenyouhave5?
  • 5. - Our current project has 45 different containers - as a side note these details can be obtained by running docker-compose config --services Or45?
  • 6. - Compose is a tool for defining and running multi-container Docker applications. - YAML file to configure your applicationʼs services. - single command, you create and start all the services from your configuration. Whatis docker-compose
  • 7. - this is a very simplistic model - 2 containers, web & api - the version number here is significant - the depends_on attribute automatically starts api if we only start web Simple docker-compose.yml version: "3.4" services: web: image: metacpan-web:lastest depends_on: - api api: image: metacpan-api:lastest
  • 8. - version 3.0 indiciates Docker Engine relase 1.33.0+ - version 3.7 indiciates Docker Engine relase 18.06.0+ - what attributes are available to be defined varies greatly - healthcheck for example is only supported from version 2.1 - while mounting volumes read-only is only available in 3.4 A word about version numbers · Dictates the version of docker · Indicative of the attributes available
  • 9. - A little side story - I had intended to use reveal.js for this presentation - the formatting and code highlighting really bugged me - I've reverted back to using DeckSet - but had I continue... - this is the run command suggested for running this presentation in a container - there are a lot of volumes to be mounted, and rerunning by hand is definitely not something you'd want to do - docker image is from https://github.com/ nbrownuk/docker-revealjs Example of docker run with many options docker run -it --rm -p 8000:8000 -v $PWD/index.html:/reveal.js/index.html -v $PWD/media:/reveal.js/media -v $PWD/custom.css:/reveal.js/css/theme/custom.css -v $PWD/menu:/reveal.js/plugin/menu nbrown/revealjs Docker image is from https://github.com/ nbrownuk/docker-revealjs
  • 10. - let's convert the docker run command from the previous slide into a working docker- compose.yml Exercise
  • 11. - when doing a conversion I like to keep the code that I'm replacing local - I comment it out and delete the bits I'm working on and paste them in the real code Converting a docker run command # docker run -it --rm -p 8000:8000 # -v $PWD/index.html:/reveal.js/index.html # -v $PWD/media:/reveal.js/media # -v $PWD/custom.css:/reveal.js/css/theme/custom.css # -v $PWD/menu:/reveal.js/plugin/menu # nbrown/revealjs
  • 12. - start off with the required bits - specify the version of the file (I want read-only mounts) - start the services definitions - name the service reveal in this case Converting a docker run command # docker run -it --rm -p 8000:8000 # -v $PWD/index.html:/reveal.js/index.html # -v $PWD/media:/reveal.js/media # -v $PWD/custom.css:/reveal.js/css/theme/custom.css # -v $PWD/menu:/reveal.js/plugin/menu # nbrown/revealjs version: "3.4" services: reveal:
  • 13. - we're going to define the image Converting a docker run command # docker run -it --rm -p 8000:8000 # -v $PWD/index.html:/reveal.js/index.html # -v $PWD/media:/reveal.js/media # -v $PWD/custom.css:/reveal.js/css/theme/custom.css # -v $PWD/menu:/reveal.js/plugin/menu # nbrown/revealjs version: "3.4" services: reveal: image: nbrown/revealjs:latest
  • 14. - we're going to define the ports in use - the first port is the external listening port, the second is the internal - this is used for when you want to access a container from the host - for the presentation I want to point my browser at 127.0.0.1:8000 - while I'm removing the ports definition from the run command, I'm going to remove the run command Converting a docker run command # docker run -it --rm -p 8000:8000 # -v $PWD/index.html:/reveal.js/index.html # -v $PWD/media:/reveal.js/media # -v $PWD/custom.css:/reveal.js/css/theme/custom.css # -v $PWD/menu:/reveal.js/plugin/menu # version: "3.4" services: reveal: image: nbrown/revealjs:latest ports: - 8000:8000
  • 15. - What I'm left with here are the volumes Converting a docker run command # # -v $PWD/index.html:/reveal.js/index.html # -v $PWD/media:/reveal.js/media # -v $PWD/custom.css:/reveal.js/css/theme/custom.css # -v $PWD/menu:/reveal.js/plugin/menu # version: "3.4" services: reveal: image: nbrown/revealjs:latest ports: - 8000:8000 volumes:
  • 16. - What I'm left with here are the volumes Converting a docker run command # # -v $PWD/index.html:/reveal.js/index.html # -v $PWD/media:/reveal.js/media # -v $PWD/custom.css:/reveal.js/css/theme/custom.css # -v $PWD/menu:/reveal.js/plugin/menu # version: "3.4" services: reveal: image: nbrown/revealjs:latest ports: - 8000:8000 volumes:
  • 17. - the first volume is for the index.html - docker volumes are defined source:destination on the command line - In the docker-compose, I'm using expanded syntax as it's easier to read and allows for more options - type is bind, because we're specifically mounting a file, a remote volume would be type volume - source - while docker-compose supports environment variables and other variables, it's not required here - destination - this is where the application in the container is expecting the file to be Converting a docker run command # # -v $PWD/index.html:/reveal.js/index.html # -v $PWD/media:/reveal.js/media # -v $PWD/custom.css:/reveal.js/css/theme/custom.css # -v $PWD/menu:/reveal.js/plugin/menu # version: "3.4" services: reveal: image: nbrown/revealjs:latest ports: - 8000:8000 volumes: - type: bind source: ./index.html target: /reveal.js/index.html read_only: true
  • 18. Complete docker-compose.yml version: "3.4" services: reveal: image: nbrown/revealjs:latest ports: - 8000:8000 volumes: - type: bind source: ./index.html target: /reveal.js/index.html read_only: true - type: bind source: ./media target: /reveal.js/media read_only: true - type: bind source: ./custom.css target: /reveal.js/css/theme/custom.css read_only: true - type: bind source: ./menu target: /reveal.js/plugin/menu read_only: true - type: bind source: ./md target: /reveal.js/md read_only: true
  • 19. - without the -d option docker-compose up will start containers and logging in the foreground - the --volumes options to docker-compose down removes any persistent storage volumes that are defined - useful if you can recreate your database from scratch - log is extremely useful if you've started containers in detached mode, it also supports -f just like tail - docker-compose was originally called fig, which is a lot less typing - create an alias, save your fingers Simple Commands · docker-compose up builds creates/recreates and attaches to containers · docker-compose down stops and removes containers, networks and volumes · docker-compose stop stops containers without removing them · docker-compose start starts existing containers for a service · docker-compose log starts existing containers for a service
  • 20. Furtherreading · Docker Compose documentation https://docs.docker.com/v17.09/compose/ overview/`
  • 21. END