You are on page 1of 101
Docker 16 An open-source Platform that Automates the deployment, SeAling, And management of applications Using containeviZation technology. Containers ave lightweight, Standalone, And executabole software gackaces that include everything needed to run a piece of Software, incliding the code, wuntime, libraries, And system tools. Vivtualization @mulates an entive operating system, while Docker ContAimerS ShAve the hoSt OS Kernel, waking, them more Nightweight and efficient. | A Docker wage 16 Q eAd-only template used to create Docker containers, Tt contains the agglication code, runtime, lilovavies, And other dependencies. 7 You create a Docker image using a VockerFile, which containg instructions for lovilding the image layer by layer A Docker container is a Woning instance of a Docker imaage, isolated from the host System And other containers. Nou use the “decker vun’ command Followed boy the name of the image to wun Docker container. The “decker 9S command disglays a list of All running containers. | The “docker stog’ command followed loy the container LD or name stors a waning container. The “docker vm’ Command followed loy the container LO ov name removes Q Stopged container. Docker Compose is A tool Used to seb And manage wiulti-contaner Docker agglications using a YAML file US2 the “docker build’ command Followed oy the path to the divectory cont dining the Docker File, i After taaging, your image with your Docker Hule USerndme And vegository, USE the “docker gush’ Command. | Use the “docker tag) command followed loy the ena LO or ndme And the desived a9, Docker Swarm iS O nOtive clustering, And orchestration Solution for Deckor Contdiners. Use the “docker Swarm init” command to initialize a Docker Swarm on @ wmanagen node ThE manager node manages the cluster And orchestrates tasks Among, worker nodes Use the “docker Swarm jin’ Command on the worker nodes, long with the Foken generated during swarm initialization Kulernetes is an open-source container orchestration glatform for Automating the deployment, ScAling, And wAnAQement of containerized Agelications. | Follow the installation instructions grovided on the Docker website for your Specific Linux distribution. 1 What i6 a Docker volume? A Docker volume 15 A divectory outside of the container’s filesystem that Allows data to persist between container restarts. UL How do you create a Docker volvene? Use the “docker vole create” command followed loy the volUen® nde Specify the volume name And mount gath in the “docker wun’ Command Using the “-v" or *--Volume” £lag, The “decker Volume ven’ Command followed loy the Volume name removes a Docker volume. The “decker inspect’ command followed ly the container LO or nde Provides detailed information About a container. The “decker image insgact’ command followed by the image name or LO Provides detailed information About An image. Use the “docker loas' command followed by the container LD o¢ name. Use the °-2' o '--2nu' Flag Followed bby the varialole name Gad value in the “docker run’ command. a Use the °-d’ or *--detach® lag, im the “docker wun’ command to run a Container in the background. Use the *-g° ov *--gublish’ £1aq followed oy the host gort And container gort in the “docker wun’ command. Docker Reaistry is a Service that stores And distviloytes Docker images. Docker Hule 15 a cloud-lbaced veaistry Service Qrovided loy Docker for Shaving And distrilouting Docker images. The “decker container erUne* Command removes All Stogeed containers. | Use the “docker exec’ command followed oy the container LY ov name And The Command to execute. 2 Build A new version of the imdae Using An uRdated Dockerfile And tag it with A new version number. | Use the *--ceus’ And “--memory’ faqs in the “decker wun’ command to limit CPU And wiemory Usage 2 A Dockerfile is a text file that contains a set of instructions for louilding, a Vocker wnaae. | Use the “COPY? o “ADD instruction in the DockerFile The “decker mages’ command lists all Docker images 2 The “decker emi’ command Followed loy the image LO or name removes a Docker image, 2 A Docker network is a virtual network that allows communication between Contdiners. Use the ‘decker network create’ command followed ley the network name. 2 Use the *--network’ Flag in the “decker wun commdad to specify the a’ Containers in the SAme network cOn communicate with each other Using Contained names or LP addresses. Use the “docker service Scale’ command followed ly the Service ndme And desived veglica count. The “decker Service 15° command lists all Seevices in a Decker Swavwn. Use the “docker Service uRPdate’ command Followed loy the Service name And desived options. | A Docker container image vaaistry i6 a Server that stores And distributes Docker mages. 49 How can you Specify a custom name for a Docker container? — Use the © --name’ £09, im the “dockee vn’ Command to Set a custom ndvne. The “docker network grune” command removes all Unused networks. The “docker volume IS° Command lists all Docker volumes, 2 Use the “-€° or *--file” Flaq im the “decker louild’ command followed boy the path to the Vockerfile. Docker image layers Ae Used Lor imcrdmentAl chanaes And oxtimization during image lovilas 2 You can use the ‘decker diff command Followed ley the container LO o¢ nde to S22 changes made to the Lilesysten, A Docker registry mirror iS A cOched copy of Docker images that con be Used to seeed ue wenage pulls. Use the “decker contaimde Stop Hdocker container IS -Aq)’ Command to Steg All Containers And then use ‘decker container erune’ to remove them | An image is a static template, while A container i6 A waning instance of an india. Use the “decker Pause” And “decker UngaUSe’ Commands followed loy the Containers LO ov Owe et Use the °--vestart® lag, in the “docker vn’ command to seecity the westart golicy. a "CMO" provides default arauments Lor An executing contdinee, while ENTRYPOINT" specifies the command to vUn when the container Starts. Use the “decker service inspect’ command followed loy the Service nde. i Use the “decker export’ command followed oy the container LD ov name. 6. what i6 Docker Machine? Docker Machine 1S A teol used to create And wmnage Decker hosts on Various cloud platforms ov local virtual machines. 2 You can set the timeZone Using the “TZ environment vavialele in the “docker Un" command, nt Upgrade instructions can vary ley operating system, refer to the of ficial Docker documentation for your specific Setur. The Vockarfile Bast Practices guide provides recommendations For writing efficient and secure Vockerfiles. i Use the *--vestart® faq with the “always agtion in the “decker un’ | You can use the “decker secret’ command to manage Secrets in Vocker Swan, 2 Use the “wesources’ Section in the “docker-composeyml file to define vesource limits For containers. 70. what i Docker Health Check? Docker Health Check is a feature that allows you to monitor the status oF A Unning Contdinee And take Action leased on its health. Use the °-v> or *--volume” a9, with An dlosolute path in the “docker run’ Command to Share a divectory, Aa image is @ vunndlele package, while a vegasitory iG a collection of images with different ta9% Use the “docker Swarm init? command to endlle Swarm mode on a wmdnager node. Use the “docker service logs’ command Followed ley the Service name. Use the *--vestart’ £la9, with the ‘on-failuee’ ogtion in the ‘docker vun* Command. ma Use Fo waltgne “FROM instvuctions im A single Docker file to create a muiti- Staqe lovild, | The * dockevignora” ile specifies files And dwectories that should be excluded from the Docker build context, Use the “docker Secret create’ command followed loy the Secret name And File garth. I Create O now Secvet with the updated content, saaite the Service to use The n@w Secret, And then vemove the old secret. 2 Use the “export DOCKER_CONTENT_TRUSTAI command to enalole Decker Content tust, which ensures the inteavity And authenticity of Docker wonages. 2 "RUN" executes commands during image build, while "CMO" specifies the Command to run when the contamer starts. The “decker Seevice 5° command lists all Seevices in the SwOrm. The "HEAL THCHECK" instruction defines how to test the health of a YUnning, Container. 2 Use the “decker ce’ command followed oy th container LD ov name And the file garth. 85, What is the Docker contort? The Docker context is the set of Files And directories used aS the build Context when creating An image. Use the “docker exec -it* command followed boy the container LO or ndme And the Shell command. "ADD" can copy Files From emote URLS and extract com@ressed Files, while “COPY only copies Files From the build context. BB. How can You check the TP address assigndd to a VockeriRontainer? Use the “docker inspect” command followed oy the container LD or name to check the container’s network settings. 89, What is the "ENTRXPOINT" SON aveay Format in a Docker File? The “ENTRYPOINT" ISON array Format Allows you to Specify oth the executable And its Avayments in A Single instruction. 90. How do you v@move all Unused Docker images, Volumes, And networks? Use the “docker system rune’ command to remove unused iwnages, Volumes, And networks, w ROR RE SDE DEG OOM Coane ae ogee Use the “docker image Is° ov “decker contamer IS command to 520 the Sizes of wenages And contdaimers. Use the “nSenter’ tool or the ‘docker exec’ command with the --gid” a ws Use the “docker service ugdate’ command with the '--vedate-delay’ And “--ugdate-parallelise’ flags, Use the *--usee’ flag in the “docker run’ Command to set the custom Use" And arour Use the *-it aq im the “docker vn’ command to enable mteractive 2 5 | i Docker Vesktog is A tool that enaleles developers to rm And manage Docker contdinecs on theiv local machine. Use the ‘decker exec’ command followed ley the container LY o name And the env’ Comendnd. FWY WHEE Pen OF TEE VOLUMES Wotvuc tion wd Uockertlle? The "VOLUME" instruction Seecifies a divactory that will be used as a mount point for A volume, 2 Use the “decker cp’ command followed oy the Source Lile on the host And the destination path in the container } Use the “docker save’ command followed ley the wage nAme And vedivect the output to a File. Docker Hub is a cloud-based veaistry Service grovided oy Docker for Shaving And distvileuting Docker images. Use the “:. | Leaping, Configuration determines how A Service's ea, output 16 hOndied, Such OS where it Stored And how it's Formatted. | US2 The “logging” Key Under the Service configuration And grovide the desived logging options, such AS driver, ertions, nd laledls. | Resource limits vestvict the Amount of CPU and memory A contamer con use, Preventing vesource contention. | Use the “wasources’ Key Under the Service Confiauration dnd grovide the desived CPU And memory limits. | Aa @nvivonment variable iS a dyndmic value that can lee passed to a Container in A Kuleemnetes god, influencing, it e2haviov. | Use the ‘env’ Key Under the “containers configuration within @ god Specification to define environment varialeles. A Configmag 16 A Kubemetes resource that Stores Configuration data in key-value Rais, which cn oe injected into Contdinees AS Qnvivonment Variables or moUnted as Files, | Define a ConfiaMa resource in a YAML file, Specifying the data using the ‘data’ field. Then, veferOnce the ConfigMa in A god's “Onv’ o¢ “ volumes’ configuration. A Secret i6 a Kubemnetes resource Used to Store Sensitive data, such as passwords or API keys, which can le injected into containers as Anvivonment Varies or moUnted as Files. De€ine a Secret vesource in a YAML file, Specifying, the data Using, +he “data Field (oaseb4-encoded). Then, reference the Secret in A god's “env’ oF ‘Volumes’ configuration. | A volume in Kubemetes allows data to gersist between container westarts And be Shaved Among, Contdiners within A god. | USE The “volumes Key Under the Rod Specification to define volume configurations, And then reference the volume in A contdiner’s “VolumeMounts’ Configuration, A VoldmeCiain Template i6 a template for creating Persistent VolumeCiaims (PCS) dynamically, Allowing gods to request And Use Storage resources. | Ye€ine A “volumeClaimTemelate’ Under the ‘volumes’ Key in the god Specification, And reference the PVC in a container’s *volumeMounts confiqueation. | An emetypir volume is a temporary volume created when a god iS launched Aind Shaw2d Oiemong Containers in the Same god VeFine An “emetyViv’ Volume Under the volumes’ Key in the god Specification, And reference The Volume in A Contdiner’s *volumeMounts® conFigueartion | A bostPath volume mounts a File ov divectory from the host system into O god, Allowing data shaving eetween the host And the god. | Vefine A “hoStPath’ volume Under the “volumes’ Key im the Rod Specification, And re-f2rence the Volume in A Contdin®r’s *VolUmeMounts” configuration Kubemetes? A Porsistent Volume (PV) 16 a cluster-wide vesource that vagrasents a Piece of networked storaae grovisiontd by An Administvator | Deine a ParsistentVolume resource in a YAML File, Specifying the storage details, Access modes, And reclaim golicy. Then, create a PorsistentValumeCiaim (PVC) in A god Specification to loind it to the PV. € A Poxsistent Volume Claim (PVC) is @ request for Storage boy a user, Specifying Storage veqvaments And Access modes Deine a Persistent VolUmeCldim resource ina YAML File, Specifying, the. STordae class, Access modes, And Storage requivaments. Then, reference the PUC im a god's * velumes® Conf iqueation A Kubemetes Service 15 An Abstract way to exgose an Agglication waning on A S0t of Rods AS A network Service. Vetine A Service vesource in a YAML ile, Seecitying the type 9, ClusterLP, NodePort, LoadBalancer), selector, And ports, Pods with wnat ching laloels will be accessilole through the Service. 2 A ClusterLP service exgoses a set of pads to other resources within the cluster, Allowing, internal Communication. | Define A Service veSource with the tyRe “ClusterIP’ in a YAML file, Specifying the selector And gorts. Pods with matching laboels will be Accessible through the Service. A NodePort service exposes a Set of gods to the outside world loy Allocating a specific gort on Gach node's TP. _configueattion? Define a Service resource with the tyge “NodePort in a YAML ile, Specifying the selector, ports, and “wedePort”. Pods with watching laleels will be accessible through the specified gort. “#19, What 6 Dockers “Coadbalancer" Service tyee in KUeernees? A LoadBalancer service automatically assigns a guiolic TP dnd routes external traffic to a set of pads. 3) Define A Service resource with the tyre “LoadBalancer’ in a YAML ile, Speci ying the Selector, gorts, And Annotations. The cloud grovider will Provision a load lalancer And forward traffic to the gods. AA what is Vocker's "Ingress" wesource in the context of Kubenetes? Aa Tngress resource allows You to manage external access to services within a cluster, typically used for HTTP and HTTPS twat tic, 4x1. How can You ex2ate And UEC On Tnqrbss wOSouree in a Kuledwnetes Ye€ine an Tnaess vesource in O YAML --dins” Flaq, followed loy the IP addresses of: the ONS sowvers. when eUnning @ Container Docker provides a uitt-in ONS Service that Allows containers to resolve Och other's names Using, thie Contaimey ndmes. | When linking containers, Docker automatically Adds entvies to the *Lerchhosts ile Lor ndme vesolvtion. | An ing? vegository is A centralized Storaae location for Docker images, Allowing 2ASY Shing And distvibution. Use the “docker gush’ command followed loy the regository name And +09 to upload the image. Docker Hule 16 A cloud-lased registry Service where You can Stove, Shave, And distriloute Docker mages. | Use the “decker gull’ command followed by +he vogository name And +aq +o download the image ot Docker Comges?e iG A tool Lov defining And wnning miti-containee AgPlications Using a single YAML configuration File. | Use the “docker-comease ur’ command in the directory containing the docker-comgose.ymnl’ File. | The “decker-camgose yon!’ ile do-£ines the configuration for a Vockor Compose agglication, including, S2evices, networks, And volumes. | Use the appropriate keys C services’, ‘networks’, ‘volumes’? in the “docker-compase.yml’ £ile And specify their configurations A seevice is a defined component of a Docker Comgose agglication, typically A Contdinevized agglication or A microservice | Use the “docker-compase ug command with the scale’ £laq, Followed loy Th SOrviCe nme And the desived number of raPlicas. A network in Docker Compose Allows Services within the Same application to Communicate with 2ach other. | Use the ‘networks’ Key Under the Service confiqueation dnd define the networks the service Should bbe commected to. 2 A Volume in Docker Comgos? Allows data to be shared and persisted loetween containers within the Same application. Use the ‘volumes’ Key Under the Service confiqueation to define the Volumes the Service Should use. An Qavivonment variable is a dynamic value that can lee passed to a Container at wUntime, influencing, its behavior. Use the “environment” Key Under the Service Configueation to define the Caviconment varies for the Service. The lovild content is the divectory or URL containing the £iles needed to lovild a Docker mage, specified in A Service's build configuration. Use the “lovild’ kay Under the service configuration And specify the gath to the build context. Container linking in Docker Comes? Allows you to establish a network connection between two containers, enaloling, Communication. Use the “links” key Under the service confiauration to define containge links for a service. The “degendson’ Key in Docker Compose specifies the order in which Seevices Should be started or dependencies loetween services. Use the “deogendson’ Key Under the Service confiquedtion to list the SOrvices that the current service degends on. The ‘ports conFigueation in Docker Compose specifies the wagging of gorts between the host And A container. Use the “ports Key Under the service configuration And specify the wagging aS “Yhost_port.container_gort!. The ‘volumes’ configuration im Docker Compose Specifies the volumes that Should lee used ley a container. Use the ‘volumes’ key Under the Service confiqueation And define the Volume magprings 05 “"hostgath.container garth The “labels confiauvation in Docker Compose Allows You to assign key-value PAWS to ContAiners, Services, And other objects. Use the “laleels’ Key Under the service Configuration And define the laleels OS a dictionary of key-value gains. The “entvygoint® configuration in Vocker Compose specifies the default CHOCUTALIE that 1S rUn WhOn A contdindr Starts. ) Use the “enteygoint’ Key Under the Service configuration And seeci€y the desived entvygoint command. | The “command configuration in Docker Compose Allows You to override the AeKaUIt command SReciFied im the containee ida. US the “Command Key Under the Service configieation And specify the desived command. The ‘exteendLlinks’ configuration in Docker Compose allows you to link Containers Lom extend Docker Compose projects. Use The “ExtemndLlinks Key Under the service configuration And specify ThE names of External Containers to be linked. The extend’ feature in Dockor Compose Allows You to "0US2 And extend configurations fram other Compose files. Use the ‘extends’ Key Under the Service configuration And sacify the File And Seevice to be extended. The “seerets’ Ceatuve in Docker Compose allows You to mAndge and Use Sensitive data securely, Such AS Passwords o¢ API keys. Define Secrets in A “Secrets Section im the Docker Compose £ile, And then use the “secvets’ Key Under the Service configuration to veference the Secvets, The ‘configs’ Feature in Docker Compose allows you to mAndae And use configuration Files that ave stored outside the Compose File. Ve€ine config ina “configs” Section in the Docker Compose file, And then U52 the ‘configs’ Kay Under the Servic? configuration to reference the configs. | The “decker tog’ command allows you to view the running Process29 within O container. Use the “decker top

You might also like