Docker
By: Abdelrehim Morsy
C2 General
Download
installer
Get another
Run installer
error !
Installing
software flow
Get error
message
Rerun installer
during
installation
Troubleshoot
issue
C2 General
End-to-end application stack
Libraries Dependencies
Host OS
Hardware Infrastructure
C2 General
virtualization
Lib Dep Lib Dep Lib Dep
OS OS OS
Hypervisor
Host OS
Hardware Infrastructure
C2 General
containerization
Lib Dep Lib Dep Lib Dep
Docker?Engine
Host OS
Hardware Infrastructure
C2 General
containerization vs virtualization
UTILIZATION SIZE BOOT UP
C2 General
Utilization Size Boot Up
containerization virtualization
containerization vs virtualization
C2 General
vocabularies
Image
• Single file with all the deps and config
required to run a program
Container
• Instance of an image. Runs a program.
C2 General
Demo
C2 General
Intro to Docker
WHY USE WHAT IS DOCKER ?
DOCKER ?
C2 General
Docker makes it really easy to install and run software
without worrying about setup or dependencies.
Short setup time.
Different Dev/Test/Prod environments.
Why use Docker !
C2 General
Docker
Docker Client
Server
Docker Docker
Machine Images What is
Docker ?
Docker
Docker HUB
Compose
▪ Docker is a platform or ecosystem around creating and
running something called containers.
▪ Docker is a tool designed to make it easier to create,
deploy, and run applications by using containers.
C2 General
Types of Docker regestries
Public
regestr
y
Private
regestr
y
C2 General
Manipulating Containers with the Docker Client
C2 General
Run Container •$ docker run <image-name>
Overriding default •$ docker run <image-name> <command!>
command
Attached and •$ docker run –d <image-name>
Detached •$ docker attach <container ID>
Interactive mode •$ docker run -i <image-name>
Docker Basic
Port mapping •$ docker run –p host:container <image-name>
Volume mapping
Commands
•$ docker run –v host:container <image-name>
Inspect container •$ docker inspect <container-name>
Stop container • $ docker stop CONTAINER
List all images •$ docker images -a
List all containers •$ docker ps -a
C2 General
Break
C2 General
Lab
C2 General
▪ Run the container hello-world
▪ Check the container status
Problem 1 ▪ Start the stopped container
▪ Remove the container
▪ Remove the image
C2 General
▪ Run container centos or ubuntu in an
interactive mode
▪ Run the following command in the container
“echo docker ”
Problem 2 ▪ Open a bash shell in the container and
touch a file named hello-docker
▪ Stop the container and remove it. Write
your comment about the file hello-docker
▪ Remove all stopped containers
C2 General
▪ Run a container httpd with name apache and
attach a volume 2 volumes to the container
▪ Volume1 for containing static html file
▪ Volume2 for containing httpd configuration
Problem 3 ▪ Remove the container
▪ Run a new container with the following:
▪ Attach the 2 volumes that was attached to the
previous container
▪ Map port 80 to port 9898 on you host machine
▪ Access the html files from your browser
C2 General
▪ Run the image httpd again without
attaching any volumes
▪ Add html static files to the container and
Problem 4
make sure they are accessible
▪ Commit the container with image name
IMAGE_NAME
▪ Create a dockerfile for the previous image
and build the image from this dockerfile
C2 General
▪ Create a volume called mysql_data, then
deploy a MySQL database called app-
database. Use the mysql latest image, and
Problem 5 use the -e flag to
set MYSQL_ROOT_PASSWORD to P4sSw0rd0
!.Mount the mysql_data volume
to /var/lib/mysql. The container should run
in the background.
C2 General
Thanks for attention
C2 General