Docsity

Docker Installation and Usage Guide on Ubuntu, Essays (high school) of Computer science

Toggle sidebar
bg1
Docker Beginners: -
What is a Docker??
Docker is an open-source platform that enables developers to build, deploy, run,
update and manage containers. Docker is a combined number of Dev
environments in a single operating system. It can create multiple containers in a
single Docker.
Ex. Like Panni puri set the entire plate we can consider the Docker.
What is a container?
Docker provides the ability to package and run an application in a loosely
isolated environment called a container. The isolation and security allow you to
run many containers simultaneously on a given host.
Ex. A Single plate of Panni puri is mixed with multiple numbers of puri is
called a container.
Docker and Container installation basic commands: -
The Ubuntu and CentOS, we are using the docker environment.
Ubuntu: -
#sudo apt-get update
#sudo apt-get install docker.io
After installation verify the docker version:
#sudo docker -v
CentOS /RHEL
#sudo yum -y install docker
#sudo systemctl start docker ; #sudo systemctl enable docker
After installation verify the docker version:
#docker -v
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Docker Installation and Usage Guide on Ubuntu and more Essays (high school) Computer science in PDF only on Docsity!

Docker Beginners: -

What is a Docker??

Docker is an open-source platform that enables developers to build, deploy, run,

update and manage containers. Docker is a combined number of Dev

environments in a single operating system. It can create multiple containers in a

single Docker.

Ex. Like Panni puri set the entire plate we can consider the Docker.

What is a container?

Docker provides the ability to package and run an application in a loosely

isolated environment called a container. The isolation and security allow you to

run many containers simultaneously on a given host.

Ex. A Single plate of Panni puri is mixed with multiple numbers of puri is

called a container.

Docker and Container installation basic commands: -

The Ubuntu and CentOS, we are using the docker environment.

Ubuntu: -

#sudo apt-get update

#sudo apt-get install docker.io

After installation verify the docker version:

#sudo docker - v

CentOS /RHEL

#sudo yum - y install docker

#sudo systemctl start docker ; #sudo systemctl enable docker

After installation verify the docker version:

#docker - v

Result docker version in ubuntu: -

ubuntu@ip- 172 - 31 - 27 - 3 : ~ $ sudo docker version Client: Version: 24.0. API version: 1. Go version: go1.20. Git commit: 24.0.5-0ubuntu1~22.04. Built: Mon Aug 21 19:50:14 2023 OS/Arch: linux/amd Context: default Server: Engine: Version: 24.0. API version: 1.43 (minimum version 1.12) Go version: go1.20. Git commit: 24.0.5-0ubuntu1~22.04. Built: Mon Aug 21 19:50:14 2023 OS/Arch: linux/amd Experimental: false containerd: Version: 1.7. GitCommit: runc: Version: 1.1.7-0ubuntu1~22.04. GitCommit: docker-init: Version: 0.19. GitCommit: ubuntu@ip- 172 - 31 - 27 - 3 : ~ $ sudo docker - v Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.

Docker commands with using docker help: -

ubuntu@ip- 172 - 31 - 27 - 3 : ~ $ docker help Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers

export Export a container's filesystem as a tar archive history Show the history of an image import Import the contents from a tarball to create a filesystem image inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images save Save one or more images to a tar archive (streamed to STDOUT by default) start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers wait Block until one or more containers stop, then print their exit codes Global Options: --config string Location of client config files (default "/home/ubuntu/.docker")

  • c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
  • D, --debug Enable debug mode
  • H, --host list Daemon socket to connect to
  • l, --log-level string Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info") --tls Use TLS; implied by --tlsverify --tlscacert string Trust certs signed only by this CA (default "/home/ubuntu/.docker/ca.pem") --tlscert string Path to TLS certificate file (default "/home/ubuntu/.docker/cert.pem") --tlskey string Path to TLS key file (default "/home/ubuntu/.docker/key.pem") --tlsverify Use TLS and verify the remote
  • v, --version Print version information and quit

Run 'docker COMMAND --help' for more information on a command. For more help on how to use Docker, head to https://docs.docker.com/go/guides/

Docker system and volume information: -

We can monitor the docker system's information.

root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 0 0 0B 0B Containers 0 0 0B 0B Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker system info Client: Version: 24.0. Context: default Debug Mode: false Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 24.0. Storage Driver: overlay Backing Filesystem: extfs Supports d_type: true Using metacopy: false Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog

Docker images: -

They are available in multiple Docker images in marketplaces. root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker search busapp root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker search httpd NAME DESCRIPTION STARS OFFICIAL AUTOMATED

  • busappbackendappknit/busapp-backend NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  • busappbackendappknit/busapp-admin
  • busappbackendappknit/webapp
  • diogoferreira/busapp_backend
  • diogoferreira/busapp
  • learnitguide/busapp
  • busappbackendappknit/busappadmin
  • psharshit17/busapp_server
  • venkatramanan83/busapp
  • jeseemka/busapp
  • sethupathisp/busapp
  • mfajunedi/busapp
  • venish22/busapp
  • mfajunedi/busapps
  • jeseemka123/busapp
  • cprakash154/busapp
  • 185912099/busappliction
  • jeseemka/busapp123
  • clearlinux/httpd httpd HyperText Transfer Protocol (HTTP) ser… httpd The Apache HTTP Server Project 4581 [OK]
  • paketobuildpacks/httpd
  • vulhub/httpd
  • jitesoft/httpd Apache httpd on Alpine linux.
  • openquantumsafe/httpd Demo of post-quantum cryptography in Apache …
  • wodby/httpd
  • avenga/httpd-static
  • dockette/httpdump
  • betterweb/httpd
  • centos/httpd- 24 - centos7 Platform for running Apache httpd 2.4 or bui… dockette/apache Apache / HTTPD 1 [OK]

manageiq/httpd Container with httpd, built on CentOS for Ma… 1 [OK] centos/httpd- 24 - centos8 3 dockerpinata/httpd 1 19022021/httpd-connection_test This httpd image will test the connectivity … 0 publici/httpd httpd:latest 1 [OK] centos/httpd 36 [OK] httpdocker/kubia 0 e2eteam/httpd 0 manasip/httpd 0 httpdss/archerysec ArcherySec repository 0 [OK] solsson/httpd-openidc mod_auth_openidc on official httpd image, ve… 2 [OK] patrickha/httpd-err 0 hypoport/httpd-cgi httpd-cgi 2 [OK]

Docker image installation: -

root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker pull httpd Using default tag: latest latest: Pulling from library/httpd 578acb154839: Pull complete c1a8c8567b78: Pull complete 10b9ab03bf45: Pull complete 74dbedf7ddc0: Pull complete 6a3b76b70f73: Pull complete Digest: sha256:4e24356b4b0aa7a961e7dfb9e1e5025ca3874c532fa5d999f13f8fc33c09d1b Status: Downloaded newer image for httpd:latest docker.io/library/httpd:latest root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker pull alpine Using default tag: latest latest: Pulling from library/alpine 96526aa774ef: Pull complete Digest: sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc Status: Downloaded newer image for alpine:latest docker.io/library/alpine:latest

Find out the container’s status: -

root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker ps - a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b07b9d1f902b httpd "httpd-foreground" 3 minutes ago Exited (0) 16 seconds ago web

Executed command will create a container with a running.

root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker run - d --name web2 httpd ee5e37f7a9a4f6d731ac50c8a51d57ba5fde6171962c920cbb467c38b7d3db2d

Docker containers: -

root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker ps - a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ee5e37f7a9a4 httpd "httpd-foreground" About a minute ago Up About a minute 80/tcp web b07b9d1f902b httpd "httpd-foreground" 5 minutes ago Exited (0) 2 minutes ago web

Login to the container: -

Syntax : sudo docker exec - it web2 (container name) /bin/sh(destination directory) root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker exec - it web2 /bin/sh

pwd

/usr/local/apache

bash

root@ee5e37f7a9a4:/usr/local/apache2# root@ee5e37f7a9a4:/usr/local/apache2# cd /bin root@ee5e37f7a9a4:/bin# pwd /bin

Directory creation on web2 container:

root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker exec web2 mkdir /tmp/karthi root@ip- 172 - 31 - 27 - 3:/home/ubuntu# docker exec web2 ls /tmp/karthi

Docker system information: -

root@ip- 172 - 31 - 27 - 3:/home/ubuntu# sudo docker info Client: Version: 24.0. Context: default Debug Mode: false Server: Containers: 2 Running: 0 Paused: 0 Stopped: 2 Images: 2 Server Version: 24.0. Storage Driver: overlay Backing Filesystem: extfs Supports d_type: true Using metacopy: false Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: runc version: init version: Security Options: apparmor seccomp Profile: builtin cgroupns Kernel Version: 6.2.0- 1014 - aws Operating System: Ubuntu 22.04.3 LTS OSType: linux