SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
Docker Workshop
A collaboration between GDSC and CSSC.
$whoami
> Ritvik Bhardwaj
> CSSC Tech Director
> Daniel Laufer
> GDSC Workshop lead
Today’s Agenda
● What is a VM?
● What is Docker?
● Hands-on activity with Docker
● Why do we need Docker?
● What is Docker compose?
● Hands-on activity with Docker-compose
What is Docker
● Software that allows you deploy your
applications in containers
● Allows you to essentially bundle up your
codebase into a package (called a
container) that can be deployed and ran
anywhere with ease.
● If it runs on one machine, it’ll run on the
rest!
Docker terminology
● DockerïŹle - the ïŹle used to tell docker how to build your image
● Image - The blueprint used to create a container, you can share this with people and
build on top of it!
● Container - The running instance of your image, usually what’s deployed
● Scaling up/down - the process in which to add more RAM and storage to a container,
allows for dynamic usage
● YAML - yet another markup language, the main language used for docker compose
● Docker Daemon - the service responsible for running the containers, (comes paired with
docker desktop and needs to be running to be able to use Docker in the ïŹrst place)
More on Containers
● A standard unit of software that packages up code and all its
dependencies so the application runs quickly and reliably from
one computing environment to another.
● Each container is created from an “image”
○ Think of an image as a template/blueprint for all the
contains that are created from it
■ Similar to how objects are created from
classes in Java, Python,etc
● Docker containers are similar to Virtual Machines in many
ways
Docker Container vs Virtual Machine
Container
Virtual Machine
Physical Server
Operating System
Container
Engine
Container
Application
Libraries
Physical Server
Operating System
Hypervisor
VM
Application
Libraries
VM
OS
Application
Libraries
OS
Container
Application
Libraries
*Slide taken from krish Chowdhary ’s WhiteVan Docker workshop
Docker Container vs Virtual Machine
Container
Virtual Machine
Physical Server
Operating System
Container
Engine
Container
Application
Libraries
Physical Server
Operating System
Hypervisor
VM
Application
Libraries
VM
OS
Application
Libraries
OS
Container
Application
Libraries
*Slide taken from krish Chowdhary ’s WhiteVan Docker workshop
So why is Docker useful?
● Say we want to manually deploy our React app on a server.
● These are the steps we’d have to take to deploy it:
1. Transfer all the ïŹles over the server
2. cd into the project directory and run npm install
Oh no! It turns out our server doesn’t have node installed. So let’s install it
3. Run npm install again
Oh no! It turns out we installed the wrong version of node and we are
unable to install our required dependencies and/or run the app
4. Run npm install again
It ïŹnally works!
So why is Docker useful?
● In this case it was diïŹƒcult to deploy our app to our server
because of missing/outdated dependencies required to run our
app
● We entered “Dependency hell” 💀😔
● It’s very diïŹƒcult to ensure our software runs on all types of
computers, operating systems, etc
● Think of having to deploy this app on many different servers,
that each can present their own unique problems!
● What if we want to scale our program up? Or if we want to
reduce it down?
Docker provides a solution to this!
How can we use Docker to avoid these issues?
● Idea:
● Ensure that the docker desktop is running
● Create a Docker image that describes how to run our react app in a container
● Push this image to docker hub (a website where you can upload the docker images
you make. Similar to GitHub)
● Pull this image from docker hub (ex. docker pull mywebsiteimage ) onto your
server
Quick example:
● docker pull hello-world
○ Found here: https://hub.docker.com/_/hello-world
● docker run hello-world
How can we use Docker to avoid these issues?
● Use the docker run <yourimagenamehere> command to create a container from the
image and start it up on your server.
● We don’t have to worry about what’s installed on the actual server (all you need is docker
installed).
● The docker container is running your website in it’s own isolated environment!
DockerïŹles in depth Specify a “base image”. Need some sort
of starting point to build our container off
of. This instead could be “ubuntu”, or
“postgres”, etc.
The directory that you want to create/use
inside the container
From our computer copy over the ïŹle
package.json into the /app directory
inside the docker container (when it’s
created)
The command that’ll be run when the
container is created
From our computer copy over all the other
ïŹles in directory ‘.’ on our computer into
the /app directory inside the container
The command that’ll be run every time we
start up the container (note: creating a
container is different from starting up a
container)
Docker Installation
Install Docker here: https://www.docker.com/products/docker-desktop
Ensure you run Docker Desktop after installing!
Docker Hub
Docker Hub
Let’s get some hands-on Docker experience!
Code we will be using is found at github.com/UTM-GDSC/docker-workshop
Some useful commands
● docker build -t docker-workshop-mar-11 .
○ The ‘.’ indicates to Docker that our DockerïŹle exists in the directory ‘.’ on our computer
○ Essentially builds our image and gives it a name of ‘docker-workshop-mar-11’
● docker run -p 3000:3000 docker-workshop-mar-11
○ Take anything arriving at port 3000 on your computer and direct it into port 3000 inside
the container
○ Docker run builds the image that we created in the previous step and then starts the
container!
● docker image rm docker-workshop-mar-11 --force
●
Docker Compose
Creating Multi-container Docker
applications
What is Docker compose?
● A tool that allows you to create and run multi-container docker applications
● You can deïŹne container restart policies for containers (what to do when a container,
stops, or exits with an error code, etc)
● You can ensure that containers are started up in a predeïŹned order
● Allows you to deïŹne how containers can communicate with each other
○ Allows you to create communication channels between your containers
● And much, much more!
What is Docker compose?
Writing Docker compose yaml ïŹles
● You write your docker compose conïŹguration in a ïŹle called docker-compose.yaml
○ You can use other ïŹle names but this is the default one
■ Example: daniel-compose.yaml is completely valid
● You will need to tell Docker about your custom naming scheme though!
○ Let’s see an example of a docker-compose ïŹle!
Running Docker compose
● First cd into the directory that contains that your docker-compose.yaml ïŹle
● You can then start up your multi-container docker application by running the command:
○ docker compose up
● Or if you wrote your code in a ïŹle named something other than docker-compose.yaml
○ docker compose -f <someïŹlename>.yml up
● Then to stop (aka shut down) your containers, run:
○ docker compose down
● Or docker-compose -f <someïŹlename>.yml down for non-default docker-compose ïŹle
names
Let’s get some hands-on Docker Compose experience!
Code we will be using is found at github.com/UTM-GDSC/docker-workshop
Thank you for Attending!

Weitere Àhnliche Inhalte

Ähnlich wie Docker workshop GDSC_CSSC

Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
nigamsajal14
 
Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptx
Vipobav
 

Ähnlich wie Docker workshop GDSC_CSSC (20)

Docker interview Questions-1.pdf
Docker interview Questions-1.pdfDocker interview Questions-1.pdf
Docker interview Questions-1.pdf
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
DevAssistant, Docker and You
DevAssistant, Docker and YouDevAssistant, Docker and You
DevAssistant, Docker and You
 
Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
 
docker.pdf
docker.pdfdocker.pdf
docker.pdf
 
DOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDESDOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDES
 
Docker up and Running For Web Developers
Docker up and Running For Web DevelopersDocker up and Running For Web Developers
Docker up and Running For Web Developers
 
Docker Up and Running for Web Developers
Docker Up and Running for Web DevelopersDocker Up and Running for Web Developers
Docker Up and Running for Web Developers
 
Docker
DockerDocker
Docker
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
 
Docker for dev
Docker for devDocker for dev
Docker for dev
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
 
Docker basic
Docker basicDocker basic
Docker basic
 
Docker introduction - Part 1
Docker introduction - Part 1Docker introduction - Part 1
Docker introduction - Part 1
 
Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptx
 
Adventures in docker compose
Adventures in docker composeAdventures in docker compose
Adventures in docker compose
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
 

Mehr von GDSC UofT Mississauga

Mehr von GDSC UofT Mississauga (20)

CSSC ML Workshop
CSSC ML WorkshopCSSC ML Workshop
CSSC ML Workshop
 
ICCIT Council × GDSC: UX / UI and Figma
ICCIT Council × GDSC: UX / UI and FigmaICCIT Council × GDSC: UX / UI and Figma
ICCIT Council × GDSC: UX / UI and Figma
 
Community Projects Info Session Fall 2023
Community Projects Info Session Fall 2023Community Projects Info Session Fall 2023
Community Projects Info Session Fall 2023
 
GDSC x Deerhacks - Origami Workshop
GDSC x Deerhacks - Origami WorkshopGDSC x Deerhacks - Origami Workshop
GDSC x Deerhacks - Origami Workshop
 
Reverse Engineering 101
Reverse Engineering 101Reverse Engineering 101
Reverse Engineering 101
 
Michael's OWASP Juice Shop Workshop
Michael's OWASP Juice Shop WorkshopMichael's OWASP Juice Shop Workshop
Michael's OWASP Juice Shop Workshop
 
MCSS × GDSC: Intro to Cybersecurity Workshop
MCSS × GDSC: Intro to Cybersecurity WorkshopMCSS × GDSC: Intro to Cybersecurity Workshop
MCSS × GDSC: Intro to Cybersecurity Workshop
 
Basics of C
Basics of CBasics of C
Basics of C
 
Discord Bot Workshop Slides
Discord Bot Workshop SlidesDiscord Bot Workshop Slides
Discord Bot Workshop Slides
 
Web Scraping Workshop
Web Scraping WorkshopWeb Scraping Workshop
Web Scraping Workshop
 
Devops Workshop
Devops WorkshopDevops Workshop
Devops Workshop
 
Express
ExpressExpress
Express
 
HTML_CSS_JS Workshop
HTML_CSS_JS WorkshopHTML_CSS_JS Workshop
HTML_CSS_JS Workshop
 
DevOps Workshop Part 1
DevOps Workshop Part 1DevOps Workshop Part 1
DevOps Workshop Part 1
 
Back-end (Flask_AWS)
Back-end (Flask_AWS)Back-end (Flask_AWS)
Back-end (Flask_AWS)
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Database Workshop Slides
Database Workshop SlidesDatabase Workshop Slides
Database Workshop Slides
 
ChatGPT General Meeting
ChatGPT General MeetingChatGPT General Meeting
ChatGPT General Meeting
 
Elon & Twitter General Meeting
Elon & Twitter General MeetingElon & Twitter General Meeting
Elon & Twitter General Meeting
 

KĂŒrzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

KĂŒrzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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...
 

Docker workshop GDSC_CSSC

  • 1. Docker Workshop A collaboration between GDSC and CSSC.
  • 2. $whoami > Ritvik Bhardwaj > CSSC Tech Director > Daniel Laufer > GDSC Workshop lead
  • 3. Today’s Agenda ● What is a VM? ● What is Docker? ● Hands-on activity with Docker ● Why do we need Docker? ● What is Docker compose? ● Hands-on activity with Docker-compose
  • 4. What is Docker ● Software that allows you deploy your applications in containers ● Allows you to essentially bundle up your codebase into a package (called a container) that can be deployed and ran anywhere with ease. ● If it runs on one machine, it’ll run on the rest!
  • 5. Docker terminology ● DockerïŹle - the ïŹle used to tell docker how to build your image ● Image - The blueprint used to create a container, you can share this with people and build on top of it! ● Container - The running instance of your image, usually what’s deployed ● Scaling up/down - the process in which to add more RAM and storage to a container, allows for dynamic usage ● YAML - yet another markup language, the main language used for docker compose ● Docker Daemon - the service responsible for running the containers, (comes paired with docker desktop and needs to be running to be able to use Docker in the ïŹrst place)
  • 6. More on Containers ● A standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. ● Each container is created from an “image” ○ Think of an image as a template/blueprint for all the contains that are created from it ■ Similar to how objects are created from classes in Java, Python,etc ● Docker containers are similar to Virtual Machines in many ways
  • 7. Docker Container vs Virtual Machine Container Virtual Machine Physical Server Operating System Container Engine Container Application Libraries Physical Server Operating System Hypervisor VM Application Libraries VM OS Application Libraries OS Container Application Libraries *Slide taken from krish Chowdhary ’s WhiteVan Docker workshop
  • 8. Docker Container vs Virtual Machine Container Virtual Machine Physical Server Operating System Container Engine Container Application Libraries Physical Server Operating System Hypervisor VM Application Libraries VM OS Application Libraries OS Container Application Libraries *Slide taken from krish Chowdhary ’s WhiteVan Docker workshop
  • 9. So why is Docker useful? ● Say we want to manually deploy our React app on a server. ● These are the steps we’d have to take to deploy it: 1. Transfer all the ïŹles over the server 2. cd into the project directory and run npm install Oh no! It turns out our server doesn’t have node installed. So let’s install it 3. Run npm install again Oh no! It turns out we installed the wrong version of node and we are unable to install our required dependencies and/or run the app 4. Run npm install again It ïŹnally works!
  • 10. So why is Docker useful? ● In this case it was diïŹƒcult to deploy our app to our server because of missing/outdated dependencies required to run our app ● We entered “Dependency hell” 💀😔 ● It’s very diïŹƒcult to ensure our software runs on all types of computers, operating systems, etc ● Think of having to deploy this app on many different servers, that each can present their own unique problems! ● What if we want to scale our program up? Or if we want to reduce it down? Docker provides a solution to this!
  • 11. How can we use Docker to avoid these issues? ● Idea: ● Ensure that the docker desktop is running ● Create a Docker image that describes how to run our react app in a container ● Push this image to docker hub (a website where you can upload the docker images you make. Similar to GitHub) ● Pull this image from docker hub (ex. docker pull mywebsiteimage ) onto your server Quick example: ● docker pull hello-world ○ Found here: https://hub.docker.com/_/hello-world ● docker run hello-world
  • 12. How can we use Docker to avoid these issues? ● Use the docker run <yourimagenamehere> command to create a container from the image and start it up on your server. ● We don’t have to worry about what’s installed on the actual server (all you need is docker installed). ● The docker container is running your website in it’s own isolated environment!
  • 13. DockerïŹles in depth Specify a “base image”. Need some sort of starting point to build our container off of. This instead could be “ubuntu”, or “postgres”, etc. The directory that you want to create/use inside the container From our computer copy over the ïŹle package.json into the /app directory inside the docker container (when it’s created) The command that’ll be run when the container is created From our computer copy over all the other ïŹles in directory ‘.’ on our computer into the /app directory inside the container The command that’ll be run every time we start up the container (note: creating a container is different from starting up a container)
  • 14. Docker Installation Install Docker here: https://www.docker.com/products/docker-desktop Ensure you run Docker Desktop after installing!
  • 17. Let’s get some hands-on Docker experience! Code we will be using is found at github.com/UTM-GDSC/docker-workshop
  • 18. Some useful commands ● docker build -t docker-workshop-mar-11 . ○ The ‘.’ indicates to Docker that our DockerïŹle exists in the directory ‘.’ on our computer ○ Essentially builds our image and gives it a name of ‘docker-workshop-mar-11’ ● docker run -p 3000:3000 docker-workshop-mar-11 ○ Take anything arriving at port 3000 on your computer and direct it into port 3000 inside the container ○ Docker run builds the image that we created in the previous step and then starts the container! ● docker image rm docker-workshop-mar-11 --force ●
  • 20. What is Docker compose? ● A tool that allows you to create and run multi-container docker applications ● You can deïŹne container restart policies for containers (what to do when a container, stops, or exits with an error code, etc) ● You can ensure that containers are started up in a predeïŹned order ● Allows you to deïŹne how containers can communicate with each other ○ Allows you to create communication channels between your containers ● And much, much more!
  • 21. What is Docker compose?
  • 22. Writing Docker compose yaml ïŹles ● You write your docker compose conïŹguration in a ïŹle called docker-compose.yaml ○ You can use other ïŹle names but this is the default one ■ Example: daniel-compose.yaml is completely valid ● You will need to tell Docker about your custom naming scheme though! ○ Let’s see an example of a docker-compose ïŹle!
  • 23.
  • 24.
  • 25.
  • 26. Running Docker compose ● First cd into the directory that contains that your docker-compose.yaml ïŹle ● You can then start up your multi-container docker application by running the command: ○ docker compose up ● Or if you wrote your code in a ïŹle named something other than docker-compose.yaml ○ docker compose -f <someïŹlename>.yml up ● Then to stop (aka shut down) your containers, run: ○ docker compose down ● Or docker-compose -f <someïŹlename>.yml down for non-default docker-compose ïŹle names
  • 27. Let’s get some hands-on Docker Compose experience! Code we will be using is found at github.com/UTM-GDSC/docker-workshop
  • 28. Thank you for Attending!