KEMBAR78
Docker | PDF | Computer File | Filename
0% found this document useful (0 votes)
19 views8 pages

Docker

The document outlines the objectives and key components of Docker, including orchestration, image management, installation, networking, security, and storage. It details commands for managing Docker images and containers, such as pulling, pushing, and removing images, as well as running and managing containers. Additionally, it provides insights into Docker's ecosystem, including the Docker Registry and Docker Hub, and includes practical installation and usage commands.

Uploaded by

ricacen763
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views8 pages

Docker

The document outlines the objectives and key components of Docker, including orchestration, image management, installation, networking, security, and storage. It details commands for managing Docker images and containers, such as pulling, pushing, and removing images, as well as running and managing containers. Additionally, it provides insights into Docker's ecosystem, including the Docker Registry and Docker Hub, and includes practical installation and usage commands.

Uploaded by

ricacen763
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

OBJECTIVES:

 Orchestration (25% of the Exam)


 Image Creation, Management, and Registry (20% of the Exam)
 Installation and Configuration (15% of the Exam)
 Networking (15% of the Exam)
 Security (15% of the Exam)
 Storage and Volumes (10% of the Exam)

Still remaining...

LayersLayers speed up the build and pull process of an image by breaking down the components
into minor pieces.

LAYERS

THEORY
Docker ecosystem
 Docker Registry: Docker maintains all the images in the registry and they can be pulled
from the registry.

 Docker Hub: This is the repository for all your custom-built images. Images can be pushed
and accessed from the Hub.
 Docker Client: Is a CLI tool used to interact with the Docker server.
 Docker Daemon: The Docker server process responsible for pulling, pushing, and building
the images. It is also used for running the container.

Install docker: sudo apt install docker.io

NOTE: Main advantage of image is that it does not install file again which was already installed in
your PC/server.

Remove docker: sudo apt-get remove docker docker-engine docker.io containerd runc

information: sudo docker info

version: docker –version/version

docker system: gets the Docker system information such as memory usage and housekeeping stuff

start/status/enable: sudo systemctl start/status/enable docker

Container status: docker stats conatainer_id

Container disk check: docker system df


IMAGES:
docker image ls --helpCommands:
inspect Display detailed information on one or more images
history Show the history of an image
ls List images
prune Remove unused images
rm Remove one or more images
import Import the container image which is exported by someone in the tar form.
Docker image import exported_container_name.tar image_new_name

pull Pull an image or a repository from a registry


push Push an image or a repository to a registry
docker push username/repository_name (which is given in tag)
build Build an image from a Docker file
load Load an image from a tar archive. Similar as import but main difference is, it load all the
information about image means version name etc.
docker load -o new_image_name.tar
save Save one or more images to a tar archive. Same as export but the main difference is that
it download/install all a packages and layers if you do not give tag, it will download all image tags.
docker image save image_name -o new_name.tar
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
docker image tag image_name docker_hub_username/repository_name
Docker Loguout as well

Image registries: Where you can upload(push) and download(pull) your image.
https://hub.docker.com/ is widely use to pull and push images.

pull image from docker hub: docker image(can use or not) pull repository:tag

Example: docker image pull nginx:latest or docker pull nginx:latest (for official).
OR
docker image pull username/helloworld:v1 (for unofficial users in docker hub).

Image listing: sudo docker images or sudo docker image ls/list

NOTE: Image only delete when all containers which are related to image are kill or stop.

Remove the image: docker image rm alpine:latest

Remove all the image: docker image rm $(docker image ls -aq) B/c nginx container was running.
NOTE: If you did not give tag, by default docker delete/install latest tag image.

CONTAINERS
docker container ls –help

Run a container: docker run -it aamirpinger/flag:latest sh or bash.


it: interaction or communication with repo.
sh/bash: terminal which is use to interaction.
exit: It help to outside of the container but container will stop when type exit.
ctrl+p+q: with the help of this command you can exit a image terminal without stop a container.

Container listing: docker container ls/list or ls -a(for stop and running both) or docker ps.

If you want to change your container name.


Example: docker run -it --name docker_test aamirpinger/helloworld:latest

If you want to rename your container.


Example: docker rename containerd_id new_name.

NOTE: When you already run your container using docker run -it command and you want to
execute again that running contianer, so you will use docker exec command for that.
Example: docker exec -it container_id sh.
NOTE: If you want to back to your terminal you will use "exit" command instead of "ctrl+p+q".
This time it will not stop the container.

Stop/Start/kill/Remove/Restart: docker container stop/killstart/rm/restart 642fea1a7634 (id).


NOTE: First you will stop container then remove it otherwise it will give an error.

Remove all containers: docker container rm $(docker image ls -aq).

There is another way to run container............


detached mode: It is use to run container in background without interacting to container terminal.
Example: docker container run -d aamirpinger/flag.
If want to publish your container to public.
Publishing port: docker container run -d -p random port:image port username:version
Example: docker container run -d -p 2022:80 aamirpinger/flag:latest
p: Publish

Container all commands:


docker container --help
1. create Create a new container but not run.
2. run Create and run a container
3. logs Fetch the activity of a container
4. inspect Display detailed information on one or more containers
5. stats Display a live stream of container(s) resource usage statistics
6. ls List containers
7. rename Rename a container
8. start Start one or more stopped containers
9. stop Stop one or more running containers
10. kill Like stop command but more brutal.
11. prune Remove all stopped containers
12. restart Restart one or more containers
13. pause Pause all processes within one or more containers
14. unpause Unpause all processes within one or more containers
15. exec Run a command in a running container
16. rm Remove one or more containers
17. top Display the running processes of a container
18. port Show port or a specific mapping for the container
19. cp Copy files/folders between a container and the local filesystem
docker container cp fileORdir_name/ container_name:/path
docker container cp copyfolder/ ng:/tmp

20. wait Block until one or more containers stop, then print their exit codes.
21. commit Create a new image from a existing container.
Docker container commit conatainer_name new_image_name.
Docker container commit -a “umair khan” -m “new image” ng new_ng

22. attach Attach local standard input, output, and error streams to a running container

23. diff Show changes to files/directories on a container's file system.

Docker container diff container_name.

C: changes
A: added
D: deleted

Watch docker container diff ng.


24. export Export a container's file system as a tar archive. Helpful when you want to give
your container to someone or use it to other PC. -o mean output.
Docker container export container_name -o file_name.tar
OR
Docker container export container_name > file_name.tar

25. update Update configuration of one or more containers


Docker Network
REFERENCE:
https://www.youtube.com/watch?v=3c-iBn73dDE&t=4984s&ab_channel=TechWorldwithNana
(1:15:12)

docker network ls: shows all created networks


docker network create name: creates name of a network

Docker history: If you want to see detail about image.


Example: docker history aamirpinger/flag:latest

docker logs: to see the docker logs


Example: docker logs id_of_the_container

Docker inspect: It give more detail about image.


Example: docker image aamirpinger/pinger:latest

You might also like