2. What is Docker? *
docker ˈdɒkə/
noun
1. a person employed in a port to load and
unload ships.
??
More technically
● Platform for Engineers/SysAdmins to
develop,ship and run applications faster
● Provides a consistent environment across Hardware/OS
and agnostic to user, in developing/deploying Applications
3. Components of Docker
● Docker Engine
○ lightweight Daemon running on host OS/machine
helps in creating containers for your application
● Docker Hub
○ Repository for maintaining container versions and
easier for sharing across members
4. What I can do with Docker?
● Isolate an application and its dependant
libraries into a separate execution
environment ( like Jailing)
● Run multiple versions of same executable
within a host OS or VM
5. How it works?
● Docker Client (Host
OS specific installation)
Communicates with Daemon to
get images/run container
● Docker Daemon
Maintains local repo of images,
container
6. Images vs Container
● Images are static/built
of software component,layers.
Snapshot of a container
● Containers are running
instance of Image and provides environment for
Applications to execute
8. Instantiate a container
● sudo docker run -t -i ubuntu /bin/bash
{ downloads “ubuntu” image from docker hub and executes “bash” ,inside shell, you can execute
command you wish }
● sudo docker ps
{ list all running containers, ‘ps -a’ to list all containers, active and stopped }
● sudo docker start “container_name”
{ if it was stopped,}
● sudo docker exec -it “container_name” /bin/bash
re use, re run an existing container to run new command
NOTE: every sudo docker run will instantiate new “container” and tracked as running or exited
to cleanup old containers , sudo docker rm “container_name”
9. Creating new Image
● New image can be created from base Image
● docker search “image”
● docker pull “image”
● docker run “image” command
● Add some packages inside the “image”
● docker commit -m =”messgae” -a =”Author”
“container id” “new-image-name”
● docker push “new-image-name”
10. Housekeeping
● docker images
{ lists all images created/downloaded from DockerHub}
● docker rmi “imagename”
{ delete image from local storage }
● docker logs “container id”
{ prints log from running container }
● docker stop/start “container id”
● “container” names are created automatically by docker if
you don’t specify
● docker port “containername” to list port redirection
11. this or that?
● docker run vs start
○ “run” creates a new container
○ “start” resumes a stopped container
● docker exec vs attach
○ “exec” creates a new process in existing container
○ “attach” use the same process (if you exit, container
is kille)