SlideShare a Scribd company logo
1 of 27
Containerization Basics
AcademyPRO
Today’s
agenda
Vocabulary
Run static website
Build & Run own image
Logs
Vocabulary: Images
Images - The file system and configuration of our application which are used to
create containers.
Vocabulary: Containers
Containers - Running instances of Docker images — containers run the actual
applications.
A container includes an application and all of its dependencies. It shares the
kernel with other containers, and runs as an isolated process in user space on
the host OS.
A list of running containers can be seen using the docker ps command.
Vocabulary: Daemon & Client
Docker daemon - The background service running on the host that manages
building, running and distributing Docker containers.
Docker client - The command line tool that allows the user to interact with the
Docker daemon.
Vocabulary: Hub
Docker Hub - A registry of Docker images. You can think of the registry as a
directory of all available Docker images.
Run a static website in a container
docker run nginx
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
585e0876dad1 nginx "nginx -g 'daemon ..." About a minute ago Up About a minute 80/tcp, 443/tcp goofy_payne
docker stop 585e0876dad1
docker rm 585e0876dad1
Run a static website in a container
(Successful)
docker run -d -P nginx
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
585e0876dad1 nginx "nginx -g 'daemon ..." About a minute ago Up About a minute 0.0.0.0:32769->80/tcp, goofy_payne
0.0.0.0:32768->443/tcp
docker port goofy_payne
443/tcp -> 0.0.0.0:32768
80/tcp -> 0.0.0.0:32769
Run a static website in a container
(Successful) Attempt #2
docker run --name static-site -d -p 8888:80 nginx
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0f21f39e4cfa nginx "nginx -g 'daemon ..." About a minute ago Up About a minute 0.0.0.0:8888->80/tcp, static-site
443/tcp
docker rm -f static-site
Docker Images
To see the list of images that are available locally on your system, run the
docker images command.
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest 00f017a8c2a6 2 months ago 1.11 MB
hello-world latest 48b5124b2768 3 months ago 1.84 kB
nginx latest 4a88d06e26f4 7 months ago 184 MB
Also you could pull a specific version of image as follows:
docker pull node:0.10
Docker search
To get a new Docker image you can either get it from a registry (such as the
Docker Hub) or create your own. There are hundreds of thousands of images
available on Docker hub. You can also search for images directly from the
command line using docker search.
Base & Child Images
An important distinction with regard to images is between base images and
child images.
Base images are images that have no parent images, usually images with an
OS like ubuntu, alpine or debian.
Child images are images that build on base images and add additional
functionality.
Official & User Images
Official
Another key concept is the idea of official images and user images. (Both of
which can be base images or child images.)
Official images are Docker sanctioned images. Docker, Inc. sponsors a
dedicated team that is responsible for reviewing and publishing all Official
Repositories content. This team works in collaboration with upstream
software maintainers, security experts, and the broader Docker
community. These are not prefixed by an organization or username. In the
list of images above, the python, node, alpine and nginx images are official
(base) images.
Official & User Images
User
User images are images created and shared by users like you. They build on
base images and add additional functionality. Typically these are
formatted as user/image-name. The user value in the image name is your
Docker Hub user or organization name.
Dockerfile commands summary
FROM
FROM starts the Dockerfile. It is a requirement that the Dockerfile must start
with the FROM command. Images are created in layers, which means you can
use another image as the base image for your own. The FROM command
defines your base layer. As arguments, it takes the name of the image.
Optionally, you can add the Docker Hub username of the maintainer and image
version, in the format username/imagename:version.
Dockerfile commands summary
RUN
RUN is used to build up the Image you're creating. For each RUN command,
Docker will run the command then create a new layer of the image. This way
you can roll back your image to previous states easily. The syntax for a RUN
instruction is to place the full text of the shell command after the RUN (e.g., RUN
mkdir /user/local/foo). This will automatically run in a /bin/sh shell.
You can define a different shell like this: RUN /bin/bash -c 'mkdir
/user/local/foo'
Dockerfile commands summary
COPY & CMD
COPY copies local files into the container.
CMD defines the commands that will run on the Image at start-up. Unlike a RUN,
this does not create a new layer for the Image, but simply runs the command.
There can only be one CMD per a Dockerfile/Image. If you need to run multiple
commands, the best way to do that is to have the CMD run a script. CMD
requires that you tell it where to run the command, unlike RUN. So example CMD
commands would be:
CMD ["python", "./app.py"]
CMD ["/bin/bash", "echo", "Hello World"]
Dockerfile commands summary
Expose & Push
EXPOSE opens ports in your image to allow communication to the outside
world when it runs in a container.
PUSH pushes your image to Docker Hub, or alternately to a private registry
Build image
docker build -t oleksandrkovalov/node_example .
docker run -d -p 8080:3000 oleksandrkovalov/node_example
Push image
docker login
docker push oleksandrkovalov/node_example
The push refers to a repository [docker.io/oleksandrkovalov/node_example]
a6cc0f5939b9: Pushed
...
5d6cbe0dbcf9: Pushed
latest: digest: sha256:239f102592ae13843da87bd61225fe40c686e869ff747f6e613dde8806c99009 size: 2837
Container logging
Container PID 1 process output can be viewed with docker logs command
Will show whatever PID 1 writes to stdout
View the output of the containers PID 1 process
docker logs <container name>
View and follow the output
docker logs -f <container name>
Container application logs
Typically, apps have a well defined log location
Map a host folder to the application’s log folder in the container
In this way you can view the log generated in the container from your host
folder
Run a container using nginx image and mount a volume to map the
/tmp/nginxlogs folder in the host to the /var/log/nginx folder in the
container
Private registry
Allows you to run own registry instead of using Docker Hub
Multiple options
Run registry server using container
Docker Hub Enterprise
Two versions
Registry 1.0 for Docker 1.5 and below
Registry 2.0 for Docker 1.6
Setting up private registry
Run a registry inside a container
Use the registry image at http://registry.hub.docker.com/u/library/registry
Image contains pre-configured registry v2.0
Run registry:
docker run -d -p 5000:5000 registry
Push and pull from private registry
First tag image with host IP or domain of registry server, then run docker
push
Tag image and specify the registry host:
docker tag <image id> localhost:5000/my-app:1.0
Push image to registry:
docker push localhost:5000/my-app:1.0
Pull image from registry:
docker pull localhost:5000/my-app:1.0
Any questions?
The end
for today :)

More Related Content

What's hot

How to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker ComposeHow to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker ComposeEvoke Technologies
 
Docker workshop
Docker workshopDocker workshop
Docker workshopEvans Ye
 
Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Will Hall
 
Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Binary Studio
 
Tech talk on docker with demo
Tech talk on docker with demoTech talk on docker with demo
Tech talk on docker with demoSandeep Karnawat
 
Docker 활용법: dumpdocker
Docker 활용법: dumpdockerDocker 활용법: dumpdocker
Docker 활용법: dumpdockerJaehwa Park
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystempsconnolly
 
Academy PRO: Docker. Part 1
Academy PRO: Docker. Part 1Academy PRO: Docker. Part 1
Academy PRO: Docker. Part 1Binary Studio
 
Vagrant and docker
Vagrant and dockerVagrant and docker
Vagrant and dockerDuckDuckGo
 
Docker 101 - Intro to Docker
Docker 101 - Intro to DockerDocker 101 - Intro to Docker
Docker 101 - Intro to DockerAdrian Otto
 
Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 4Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 4Binary Studio
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basicsWalid Ashraf
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with dockerGiacomo Bagnoli
 

What's hot (19)

How to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker ComposeHow to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker Compose
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers
 
Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4
 
Tech talk on docker with demo
Tech talk on docker with demoTech talk on docker with demo
Tech talk on docker with demo
 
Docker
DockerDocker
Docker
 
Docker 활용법: dumpdocker
Docker 활용법: dumpdockerDocker 활용법: dumpdocker
Docker 활용법: dumpdocker
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
 
Academy PRO: Docker. Part 1
Academy PRO: Docker. Part 1Academy PRO: Docker. Part 1
Academy PRO: Docker. Part 1
 
Docker by Example - Quiz
Docker by Example - QuizDocker by Example - Quiz
Docker by Example - Quiz
 
Workshop Docker for DSpace
Workshop Docker for DSpaceWorkshop Docker for DSpace
Workshop Docker for DSpace
 
Vagrant and docker
Vagrant and dockerVagrant and docker
Vagrant and docker
 
Docker 101 - Intro to Docker
Docker 101 - Intro to DockerDocker 101 - Intro to Docker
Docker 101 - Intro to Docker
 
Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 4Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 4
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
Docker Workshop
Docker WorkshopDocker Workshop
Docker Workshop
 
A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 

Similar to Academy PRO: Docker. Lecture 2

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 ContainerGuido Schmutz
 
Tips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podmanTips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podmanThierry Gayet
 
Docker interview Questions-2.pdf
Docker interview Questions-2.pdfDocker interview Questions-2.pdf
Docker interview Questions-2.pdfYogeshwaran R
 
Dockers and containers basics
Dockers and containers basicsDockers and containers basics
Dockers and containers basicsSourabh Saxena
 
Docker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini AnandDocker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini AnandPRIYADARSHINI ANAND
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruSwaminathan Vetri
 
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
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with dockerMichelle Liu
 
Beyond Virtualisation
Beyond VirtualisationBeyond Virtualisation
Beyond VirtualisationRightster
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101Naukri.com
 

Similar to Academy PRO: Docker. Lecture 2 (20)

Docker
DockerDocker
Docker
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
docker.pdf
docker.pdfdocker.pdf
docker.pdf
 
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
 
Tips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podmanTips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podman
 
Docker interview Questions-2.pdf
Docker interview Questions-2.pdfDocker interview Questions-2.pdf
Docker interview Questions-2.pdf
 
Docker.pdf
Docker.pdfDocker.pdf
Docker.pdf
 
Docker Presentation
Docker Presentation Docker Presentation
Docker Presentation
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Dockers and containers basics
Dockers and containers basicsDockers and containers basics
Dockers and containers basics
 
Docker
DockerDocker
Docker
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
 
Docker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini AnandDocker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini Anand
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
 
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
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
Beyond Virtualisation
Beyond VirtualisationBeyond Virtualisation
Beyond Virtualisation
 
Docker
DockerDocker
Docker
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 

More from Binary Studio

Academy PRO: D3, part 3
Academy PRO: D3, part 3Academy PRO: D3, part 3
Academy PRO: D3, part 3Binary Studio
 
Academy PRO: D3, part 1
Academy PRO: D3, part 1Academy PRO: D3, part 1
Academy PRO: D3, part 1Binary Studio
 
Academy PRO: Cryptography 3
Academy PRO: Cryptography 3Academy PRO: Cryptography 3
Academy PRO: Cryptography 3Binary Studio
 
Academy PRO: Cryptography 1
Academy PRO: Cryptography 1Academy PRO: Cryptography 1
Academy PRO: Cryptography 1Binary Studio
 
Academy PRO: Advanced React Ecosystem. MobX
Academy PRO: Advanced React Ecosystem. MobXAcademy PRO: Advanced React Ecosystem. MobX
Academy PRO: Advanced React Ecosystem. MobXBinary Studio
 
Binary Studio Academy 2017: JS team project - Orderly
Binary Studio Academy 2017: JS team project - OrderlyBinary Studio Academy 2017: JS team project - Orderly
Binary Studio Academy 2017: JS team project - OrderlyBinary Studio
 
Binary Studio Academy 2017: .NET team project - Unicorn
Binary Studio Academy 2017: .NET team project - UnicornBinary Studio Academy 2017: .NET team project - Unicorn
Binary Studio Academy 2017: .NET team project - UnicornBinary Studio
 
Academy PRO: React native - miscellaneous
Academy PRO: React native - miscellaneousAcademy PRO: React native - miscellaneous
Academy PRO: React native - miscellaneousBinary Studio
 
Academy PRO: React native - publish
Academy PRO: React native - publishAcademy PRO: React native - publish
Academy PRO: React native - publishBinary Studio
 
Academy PRO: React native - navigation
Academy PRO: React native - navigationAcademy PRO: React native - navigation
Academy PRO: React native - navigationBinary Studio
 
Academy PRO: React native - building first scenes
Academy PRO: React native - building first scenesAcademy PRO: React native - building first scenes
Academy PRO: React native - building first scenesBinary Studio
 
Academy PRO: React Native - introduction
Academy PRO: React Native - introductionAcademy PRO: React Native - introduction
Academy PRO: React Native - introductionBinary Studio
 
Academy PRO: Push notifications. Denis Beketsky
Academy PRO: Push notifications. Denis BeketskyAcademy PRO: Push notifications. Denis Beketsky
Academy PRO: Push notifications. Denis BeketskyBinary Studio
 
Academy PRO: Docker. Lecture 1
Academy PRO: Docker. Lecture 1Academy PRO: Docker. Lecture 1
Academy PRO: Docker. Lecture 1Binary Studio
 
Academy PRO: Node.js - miscellaneous. Lecture 5
Academy PRO: Node.js - miscellaneous. Lecture 5Academy PRO: Node.js - miscellaneous. Lecture 5
Academy PRO: Node.js - miscellaneous. Lecture 5Binary Studio
 
Academy PRO: Node.js in production. lecture 4
Academy PRO: Node.js in production. lecture 4Academy PRO: Node.js in production. lecture 4
Academy PRO: Node.js in production. lecture 4Binary Studio
 
Academy PRO: Node.js alternative stacks. Lecture 3
Academy PRO: Node.js alternative stacks. Lecture 3Academy PRO: Node.js alternative stacks. Lecture 3
Academy PRO: Node.js alternative stacks. Lecture 3Binary Studio
 
Academy PRO: Node.js default stack. Lecture 2
Academy PRO: Node.js default stack. Lecture 2Academy PRO: Node.js default stack. Lecture 2
Academy PRO: Node.js default stack. Lecture 2Binary Studio
 
Academy PRO: Node.js platform. Lecture 1
Academy PRO: Node.js platform. Lecture 1  Academy PRO: Node.js platform. Lecture 1
Academy PRO: Node.js platform. Lecture 1 Binary Studio
 
SubmitJS: Developing desktop applications with Electron. Mykyta Semenistyi
SubmitJS: Developing desktop applications with Electron. Mykyta SemenistyiSubmitJS: Developing desktop applications with Electron. Mykyta Semenistyi
SubmitJS: Developing desktop applications with Electron. Mykyta SemenistyiBinary Studio
 

More from Binary Studio (20)

Academy PRO: D3, part 3
Academy PRO: D3, part 3Academy PRO: D3, part 3
Academy PRO: D3, part 3
 
Academy PRO: D3, part 1
Academy PRO: D3, part 1Academy PRO: D3, part 1
Academy PRO: D3, part 1
 
Academy PRO: Cryptography 3
Academy PRO: Cryptography 3Academy PRO: Cryptography 3
Academy PRO: Cryptography 3
 
Academy PRO: Cryptography 1
Academy PRO: Cryptography 1Academy PRO: Cryptography 1
Academy PRO: Cryptography 1
 
Academy PRO: Advanced React Ecosystem. MobX
Academy PRO: Advanced React Ecosystem. MobXAcademy PRO: Advanced React Ecosystem. MobX
Academy PRO: Advanced React Ecosystem. MobX
 
Binary Studio Academy 2017: JS team project - Orderly
Binary Studio Academy 2017: JS team project - OrderlyBinary Studio Academy 2017: JS team project - Orderly
Binary Studio Academy 2017: JS team project - Orderly
 
Binary Studio Academy 2017: .NET team project - Unicorn
Binary Studio Academy 2017: .NET team project - UnicornBinary Studio Academy 2017: .NET team project - Unicorn
Binary Studio Academy 2017: .NET team project - Unicorn
 
Academy PRO: React native - miscellaneous
Academy PRO: React native - miscellaneousAcademy PRO: React native - miscellaneous
Academy PRO: React native - miscellaneous
 
Academy PRO: React native - publish
Academy PRO: React native - publishAcademy PRO: React native - publish
Academy PRO: React native - publish
 
Academy PRO: React native - navigation
Academy PRO: React native - navigationAcademy PRO: React native - navigation
Academy PRO: React native - navigation
 
Academy PRO: React native - building first scenes
Academy PRO: React native - building first scenesAcademy PRO: React native - building first scenes
Academy PRO: React native - building first scenes
 
Academy PRO: React Native - introduction
Academy PRO: React Native - introductionAcademy PRO: React Native - introduction
Academy PRO: React Native - introduction
 
Academy PRO: Push notifications. Denis Beketsky
Academy PRO: Push notifications. Denis BeketskyAcademy PRO: Push notifications. Denis Beketsky
Academy PRO: Push notifications. Denis Beketsky
 
Academy PRO: Docker. Lecture 1
Academy PRO: Docker. Lecture 1Academy PRO: Docker. Lecture 1
Academy PRO: Docker. Lecture 1
 
Academy PRO: Node.js - miscellaneous. Lecture 5
Academy PRO: Node.js - miscellaneous. Lecture 5Academy PRO: Node.js - miscellaneous. Lecture 5
Academy PRO: Node.js - miscellaneous. Lecture 5
 
Academy PRO: Node.js in production. lecture 4
Academy PRO: Node.js in production. lecture 4Academy PRO: Node.js in production. lecture 4
Academy PRO: Node.js in production. lecture 4
 
Academy PRO: Node.js alternative stacks. Lecture 3
Academy PRO: Node.js alternative stacks. Lecture 3Academy PRO: Node.js alternative stacks. Lecture 3
Academy PRO: Node.js alternative stacks. Lecture 3
 
Academy PRO: Node.js default stack. Lecture 2
Academy PRO: Node.js default stack. Lecture 2Academy PRO: Node.js default stack. Lecture 2
Academy PRO: Node.js default stack. Lecture 2
 
Academy PRO: Node.js platform. Lecture 1
Academy PRO: Node.js platform. Lecture 1  Academy PRO: Node.js platform. Lecture 1
Academy PRO: Node.js platform. Lecture 1
 
SubmitJS: Developing desktop applications with Electron. Mykyta Semenistyi
SubmitJS: Developing desktop applications with Electron. Mykyta SemenistyiSubmitJS: Developing desktop applications with Electron. Mykyta Semenistyi
SubmitJS: Developing desktop applications with Electron. Mykyta Semenistyi
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 

Academy PRO: Docker. Lecture 2

  • 3. Vocabulary: Images Images - The file system and configuration of our application which are used to create containers.
  • 4. Vocabulary: Containers Containers - Running instances of Docker images — containers run the actual applications. A container includes an application and all of its dependencies. It shares the kernel with other containers, and runs as an isolated process in user space on the host OS. A list of running containers can be seen using the docker ps command.
  • 5. Vocabulary: Daemon & Client Docker daemon - The background service running on the host that manages building, running and distributing Docker containers. Docker client - The command line tool that allows the user to interact with the Docker daemon.
  • 6. Vocabulary: Hub Docker Hub - A registry of Docker images. You can think of the registry as a directory of all available Docker images.
  • 7. Run a static website in a container docker run nginx docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 585e0876dad1 nginx "nginx -g 'daemon ..." About a minute ago Up About a minute 80/tcp, 443/tcp goofy_payne docker stop 585e0876dad1 docker rm 585e0876dad1
  • 8. Run a static website in a container (Successful) docker run -d -P nginx docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 585e0876dad1 nginx "nginx -g 'daemon ..." About a minute ago Up About a minute 0.0.0.0:32769->80/tcp, goofy_payne 0.0.0.0:32768->443/tcp docker port goofy_payne 443/tcp -> 0.0.0.0:32768 80/tcp -> 0.0.0.0:32769
  • 9. Run a static website in a container (Successful) Attempt #2 docker run --name static-site -d -p 8888:80 nginx docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0f21f39e4cfa nginx "nginx -g 'daemon ..." About a minute ago Up About a minute 0.0.0.0:8888->80/tcp, static-site 443/tcp docker rm -f static-site
  • 10. Docker Images To see the list of images that are available locally on your system, run the docker images command. docker images REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 00f017a8c2a6 2 months ago 1.11 MB hello-world latest 48b5124b2768 3 months ago 1.84 kB nginx latest 4a88d06e26f4 7 months ago 184 MB Also you could pull a specific version of image as follows: docker pull node:0.10
  • 11. Docker search To get a new Docker image you can either get it from a registry (such as the Docker Hub) or create your own. There are hundreds of thousands of images available on Docker hub. You can also search for images directly from the command line using docker search.
  • 12. Base & Child Images An important distinction with regard to images is between base images and child images. Base images are images that have no parent images, usually images with an OS like ubuntu, alpine or debian. Child images are images that build on base images and add additional functionality.
  • 13. Official & User Images Official Another key concept is the idea of official images and user images. (Both of which can be base images or child images.) Official images are Docker sanctioned images. Docker, Inc. sponsors a dedicated team that is responsible for reviewing and publishing all Official Repositories content. This team works in collaboration with upstream software maintainers, security experts, and the broader Docker community. These are not prefixed by an organization or username. In the list of images above, the python, node, alpine and nginx images are official (base) images.
  • 14. Official & User Images User User images are images created and shared by users like you. They build on base images and add additional functionality. Typically these are formatted as user/image-name. The user value in the image name is your Docker Hub user or organization name.
  • 15. Dockerfile commands summary FROM FROM starts the Dockerfile. It is a requirement that the Dockerfile must start with the FROM command. Images are created in layers, which means you can use another image as the base image for your own. The FROM command defines your base layer. As arguments, it takes the name of the image. Optionally, you can add the Docker Hub username of the maintainer and image version, in the format username/imagename:version.
  • 16. Dockerfile commands summary RUN RUN is used to build up the Image you're creating. For each RUN command, Docker will run the command then create a new layer of the image. This way you can roll back your image to previous states easily. The syntax for a RUN instruction is to place the full text of the shell command after the RUN (e.g., RUN mkdir /user/local/foo). This will automatically run in a /bin/sh shell. You can define a different shell like this: RUN /bin/bash -c 'mkdir /user/local/foo'
  • 17. Dockerfile commands summary COPY & CMD COPY copies local files into the container. CMD defines the commands that will run on the Image at start-up. Unlike a RUN, this does not create a new layer for the Image, but simply runs the command. There can only be one CMD per a Dockerfile/Image. If you need to run multiple commands, the best way to do that is to have the CMD run a script. CMD requires that you tell it where to run the command, unlike RUN. So example CMD commands would be: CMD ["python", "./app.py"] CMD ["/bin/bash", "echo", "Hello World"]
  • 18. Dockerfile commands summary Expose & Push EXPOSE opens ports in your image to allow communication to the outside world when it runs in a container. PUSH pushes your image to Docker Hub, or alternately to a private registry
  • 19. Build image docker build -t oleksandrkovalov/node_example . docker run -d -p 8080:3000 oleksandrkovalov/node_example
  • 20. Push image docker login docker push oleksandrkovalov/node_example The push refers to a repository [docker.io/oleksandrkovalov/node_example] a6cc0f5939b9: Pushed ... 5d6cbe0dbcf9: Pushed latest: digest: sha256:239f102592ae13843da87bd61225fe40c686e869ff747f6e613dde8806c99009 size: 2837
  • 21. Container logging Container PID 1 process output can be viewed with docker logs command Will show whatever PID 1 writes to stdout View the output of the containers PID 1 process docker logs <container name> View and follow the output docker logs -f <container name>
  • 22. Container application logs Typically, apps have a well defined log location Map a host folder to the application’s log folder in the container In this way you can view the log generated in the container from your host folder Run a container using nginx image and mount a volume to map the /tmp/nginxlogs folder in the host to the /var/log/nginx folder in the container
  • 23. Private registry Allows you to run own registry instead of using Docker Hub Multiple options Run registry server using container Docker Hub Enterprise Two versions Registry 1.0 for Docker 1.5 and below Registry 2.0 for Docker 1.6
  • 24. Setting up private registry Run a registry inside a container Use the registry image at http://registry.hub.docker.com/u/library/registry Image contains pre-configured registry v2.0 Run registry: docker run -d -p 5000:5000 registry
  • 25. Push and pull from private registry First tag image with host IP or domain of registry server, then run docker push Tag image and specify the registry host: docker tag <image id> localhost:5000/my-app:1.0 Push image to registry: docker push localhost:5000/my-app:1.0 Pull image from registry: docker pull localhost:5000/my-app:1.0