Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Docker Engine Architecture =

Docker CLI -> REST API -> Docker Daemon (Imagges, Voolumes, Networks) -> containerd
(Manage Containers) -> containerd-shim -> runc (run containers) -> libcontainer ->
namespace and CGroups

docker version = for detailed docker client and server information


docker --version = for client version information
docker system info = for more detailed information on dockers and images

Docker Installation =
Remove older versions if any client or engine

sudo yum install -y yum-utils


sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-
ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-
compose-plugin
sudo systemctl start docker
sudo docker run hello-world

Docker Install from a package =


Go to https://download.docker.com/linux/centos/ and choose your version of CentOS.
Then browse to x86_64/stable/Packages/ and download the .rpm file for the Docker
version you want to install.
sudo yum install /path/to/package.rpm
sudo systemctl start docker
sudo docker run hello-world

Install from script -


curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh --dry-run
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Executing docker install script, commit: 7cae5f8b0decc17d6571f9f52eb840fbc13b2737
<...>

dockerd is a way to start docker in the foreground alternate to systemctl start


docker but only used to troubleshoot
/var/lib/container = has image, container all information

Basic Container Operations =

docker container create httpd = Will pull the image from hub and doesn't run
docker container ls = to see running container
docker ls -a = to see all statuses containers
docker container ls -q = display short container id
docker container ls -aq = display short container id for all statuses
docker container start <container id>

docker container run = this pulls and runs the image


docker container run -it ubuntu = this connects to the container in interactive
mode
docker container run -itd --name=webapp ubuntu = to specify the name
docker container run -it --name=webapp --hostname=webapp ubuntu = to specify the
hostname for the container
docker container run -itd rename webapp custom-webapp = to rename the container
docker container run -d httpd = to run container in the detached mode meaning
running in the background
docker container attached <container id> = to attached back to the container
PRESS CTRL+p+q = Once in the container bash screen to go to detached mode again and
still run the container

docker container pause webapp


docker container unpause webapp
docker container stop webapp
docker container kill --signal=9 webapp

docker container stop webapp


docker container rm webapp

docker container stop $(docker container ls -q)


docker container rm $(docker container ls -aq)
docker container prune = to delete all containers

docker container run -rm ubuntu expr 4 + 5 = this will remove the container after
the program is executed

docker container run --restart=no ubuntu


docker container run --restart=on-failure ubuntu
docker container run --restart=always ubuntu
docker container run --restart=unless-stopped ubuntu

docker container cp /tmp/brahma.txt /webapp:/tmp/web.conf

docker container exec 10ff7ae8ba2c hostname = to add commands in the detached mode
docker container exec -it 10ff7ae8ba2c /bin/bash = to get back to attached mode
docker container attach 10ff7ae8ba2c = same as above

Inspect =
docker container stats = gives stats of all running containers
docker container top <container id> = gives tops information

Logs =
docker container logs <container id> = to see container logs
docker containers logs -f <container id> = to see logs refreshing in real time
docker system events --since 60m = to see system events on all containers

Logging Driver =
By default the logging drvier is in json format
We change that to syslog, splunk or any other supported drivers
vi /etc/docker/daemon.json and update the drivers
reload daemon

Port Mappings or Publishing Ports =


Publishing Container IP:
docker run -p <container_ip>:<container_port>:<host_port> <image_name>
docker run -p 192.168.1.100:8080:80 nginx

Publishing Docker Host IP:


docker run -p <host_ip>:<host_port>:<container_port> <image_name>
docker run -p 8080:80 nginx

Docker Debug Mode =


docker system info | grep -i Debug = to debug daemon issues

You might also like