Docker Assignment & Projects
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
How to submit assignment?
Write Ansswer for the following questions and submit answer at BestDevOps.com as new post for each questions
1. Components of Docker and its Brief Summary
docker client – a way for docker users to communicate with Docker
docker host – consists dockerd(daemon),containers and images
registry – stores images. we can use docker pull to pull images from registry.
2. What is the differenet between docker pause and unpause?
pause – to stop the process running inside containers
inpause- to resume the paused process inside containers
3. What is the differenet between docker stop and kill?
– docker stop command stops the containers gracefully where as kill command terminates the entrypoint process abruptly(which can incurr of data or damage to file system)
4. What is the differenet between docker exec and attach?
– attach – used for trouble shooting , to exit container to should be stopped.not user friendly to run the commands.
– exec – we can get into running container and commands.
5. List of dockerfile instructions and its Brief Summary?
– FROM – to pull base images like alpine,ubuntu,etc..
– ADD – add the files to the images(ADD supports remote urls(not encourged to use) and automaticalls unzips tar balls
– RUN – executes durint the image creation like RUN apk add wget
– COPY – copy the files to images
– EXPOSE – expose the port of the container
– ENRTYPOINT[“java”,”jar”,”webappp.jar”] start the process you want to run after staring the container]
– CMD – to pass on defaults for for an container.the paramenters for entry point can be passed using CMD.
example :
CMD[“192.168.1.1”]
ENTRYPOINT[“ping”,”-t”,”5″]
this will ping the ip provided in CMD 5 times
6. What is the differenet between CMD vs Entrypoint
– ENRTYPOINT[“java”,”jar”,”webappp.jar”] start the process you want to run after staring the container]
– CMD – to pass on defaults for for an container.the paramenters for entry point can be passed using CMD.
example :
CMD[“192.168.1.1”]
ENTRYPOINT[“ping”,”-t”,”5″]
1) Docker Components:
a) Docker engine
b) VM image = bootfs+rootfs+userfs+apps
c) Docker Images = rootfs + userfs + apps
When we create one container one copy of image is mounted into container.
2) Docker pause will pause the running container and unpause will start the pause container.
docker pause/unpause container id/ container name
3) A docker STOP command issues a SIGTERM signal to the main process running within the container while KILL command issues a SIGKILL signal to the process.
4) Use docker attach to attach terminal’s standard input, output, and error (or any combination of the three) to a running container using the container’s ID or name. This allows to view its ongoing output or to control it interactively, as though the commands were running directly in terminal.
Docker exec is a command that allows the execution of any given command within a Docker container.
5) FROM must be the first non-comment instruction in the Dockerfile
The MAINTAINER instruction allows you to set the Author field of the generated images.
RUN (shell form, the command is run in a shell, which by default is /bin/sh -c on Linux or cmd /S /C on Windows)
The LABEL instruction adds metadata to an image.
EXPOSE : Informs Docker that the container listens on the specified network port(s) at runtime.
6) ENRTYPOINT : It start the process want to run after staring the container]
CMD :To pass on defaults to container the paramenters for entry point can be passed using CMD.
1.Docker client enables user to interact with the docker
Docker host provides complete environment to execute and run applications.
DockERD is a background that manages images, containers, nerworks and storage volumes.
Docker containers provide lightweight and platform independent way of running your applications .
2.pause th process but still keep the memory portion when the container is paused. While unpause ti reduce the paused process inside the container
3 docket stop command stops the container abruptly and provides a safe way out. docker kill terminates the entry point and provides unsafe exit
4.the docker container was started using /bin/bash command, you can access it using attach, if not then you need to execute the command to create a bash instance inside the container using exec. Attach isn’t for running an extra thing in a container, it’s for attaching to the running process.
6. The purpose of cmd is to provide defaults to container
Entrypoint helps to configure a container and you can run as executable.
5. docker –version
This command is used to get the currently installed version of docker
docker pull
Usage: docker pull
This command is used to pull images from the docker repository(hub.docker.com)
docker run
Usage: docker run -it -d
This command is used to create a container from an image
docker ps
This command is used to list the running containers
1. Docker works via a Docker engine that is composed of two key elements: a server and a client; and the communication between the two is via REST API.
The server communicates the instructions to the client.
2. What is the difference between docker pause and docker unpause? Docker pause suspends all the process to container.
Docker unpause will un-suspend all the process to container.
3. docker stop: Stop a running container (send SIGTERM, and then SIGKILL after grace period) The main process inside…
docker kill: Kill a running container (send SIGKILL, or specified signal) The main process inside the container…
4. Both docker exec and attach are used to connect or access the container but only difference is that docker exec creates a
differrent process to access the container whereas docker attach connects to the same standard input/out or the same terminal.
5. There are a variety of Dockerfile instructions we can put in our Dockerfile. These include FROM, RUN, WORKDIR, COPY, ADD, VOLUME, CMD, ENTRYPOINT, WORKDIR, USER, ONBUILD, LABEL, ARG, SHELL, HEALTHCHECK, EXPOSE and ENV.
You can see a full list of the available Dockerfile instructions here.
6. ENTRYPOINT should be defined when using the container as an executable. CMD should be used as a way of defining default arguments for an ENTRYPOINT command or for executing an ad-hoc command in a container.
CMD will be overridden when running the container with alternative arguments.
Components of Docker and its Brief Summary1 Docker client: it is used to communicate with the docker server (dockerd)
2 Docker server: it contains dockerd and container
Docker image: the docker templet which contains info of the docker container.
Docker registry : library of images .
Docker container: the full package which we required to run an application .
What is the difference between docker pause and unpause?pause: to stop the process running inside containers.
unpause- to resume the paused process inside containers.
What is the difference between docker stop and kill?Docker stop: stop a running container
Docker kill: kills a running container.
What is the difference between docker exec and attach?Docker exec: will enter into the container and start interacting.
by using >> docker exec -it NAME /bin/bash
Docker attach: it will directly take us to PID 1 of the container, we use this for troubleshooting
by using docker attach NAME
List of docker file instructions and its Brief Summary?FROM: create a base image like httpd , ubuntu.
RUN: to build the container
MAINTAINER: creator of images.
ENV: an environment for image
COPY: copy the file to images
What is the difference between CMD vs EntrypointENTRYPOINT: act as an entry point to the container.
CMD: we use to set the commend it will execute while running the container.
1. Components of Docker and its Brief Summary
Docker client and server collectively called as docker engine
Registry (remote as well as Local)
Docker image and containers
2. What is the differenet between docker pause and unpause?
Pause # the container process remains active but all container specific services stop transactions
Unpause # resumes
3. What is the differenet between docker stop and kill?
Docker stop # shuts down the container process
Docker kill # removes the container
4. What is the differenet between docker exec and attach?
Docker exec # runs a process insdie the container by invoking the command from host
Docker attach # docker start + docker exec to prevent PID conflict during container creation
5. List of dockerfile instructions and its Brief Summary?
Dockerfile briefly covers the name of image , additional software installation , binding or copying the source code from the repository path and the initial executions
This can be used by using statements with functions like Pull , run ,add ,copy etc
6. What is the differenet between CMD vs Entrypoint
Entrypoint Starts a process after starting the container and CMD defines the default parameters to be used along with entry point command
https://github.com/ashishdevops123/assignments.git
Components of docker and its brief summary
main components of docker are
Docker Swarm – Docker swarm is an orchestration service within docker that allows us to manage and handle multiple containers at the same time.
Docker Images – Docker images act as a set of instructions to build a docker container.
Docker Compose – Compose is a tool for running multiple containers.
difference between pause and unpause
docker pause will suspends all the processes inside the container,where as unpause will resume the processes
Difference between kill and stop
Docker kill will kill one or more containers .Docker stop will stop the running container
Components of docker and its brief summary
main components of docker are
Docker Swarm – Docker swarm is an orchestration service within docker that allows us to manage and handle multiple containers at the same time.
Docker Images – Docker images act as a set of instructions to build a docker container.
Docker Compose – Compose is a tool for running multiple containers.
difference between pause and unpause
docker pause will suspends all the processes inside the container,where as unpause will resume the processes
Difference between kill and stop
Docker kill will kill one or more containers .Docker stop will stop the running container
1. Components of Docker and its Brief Summary
Docker client – Docker user to communicate with Docker
Docker host – It Consists of dockerd(daemon),containers and images
Registry – It stores images where we can use docker pull to pull images from registry.
2. What is the differenet between docker pause and unpause?
Pause is to stop the process running inside containers
Unpause is to resume the paused process inside containers
3. What is the differenet between docker stop and kill?
Docker stop command stop a running container by sending SIGTERM signal to the root (PID 1) in container.
Docker kill command kills one or more containers.
4. What is the differenet between docker exec and attach?
Docker exec executes new command or create a new process in container
Docker attach conncects the standard input/output/error of main process inside the container.
5. List of dockerfile instructions and its Brief Summary?
FROM: Create a basic image like httpd.
RUN: It is to build the container
MAINTAINER: Creates the images.
ENV: Environment for image.
COPY: Copies the file to images.
6. What is the differenet between CMD vs Entrypoint?
CMD commands are ignored by Daemon when there are parameters stated within the docker run command.
ENTRYPOINT instructions are not ignored but instead are appended as command line parameters by treating those as arguments of the command.
7. List of 20 docker commands and its use cases with example?
Docker version
We usually start by finding the installed version of docker that we are working on.
Docker search
The “docker search” command searches for specific images through the Docker hub. This command returns the specific information, including image name, description, automated, official stars, etc.
Docker pull
As the name suggests, this command pulls a specific image from the Docker Hub. All you have to do is use the command ‘docker pull’ along with the name of the image. Here is an example of pulling an image without using the tag.
Docker run
This command is used to create a container from an image.
Docker ps
This command is used to list all the running containers in the background.
Docker stop
The ‘docker stop’ command stops a container using the container name or its id.
Docker restart
This command is used to restart the stopped container. It is recommended to use this after rebooting the system.
Docker kill
This command is used to stop the container immediately by killing its execution. While the ‘docker stop’ command helps shut down the container in its own time, the ‘docker kill’ command stops it at once.
Docker exec
This command is used to access the container that is running.
Docker login
This command helps you to log into your docker hub. As you try to log in, you will be asked to give your docker hub credentials.
Docker commit
This command is used to create or save an image of the edited container on the local system.
Docker push
This command helps push or upload a docker image on the repository or the docker hub.
Docker network
The ‘docker network’ command is used to know the details of the list of networks in the cluster.
Docker rmi
This command is used to free up some disk space. The image id is used to remove the image while using this command.
Docker ps -a
This command is used to know the details of all the running, stopped, or exited containers.
Docker copy
This command copies a file from docker to the local system.
Docker logs
This command is used to check the logs of all the docker containers with the corresponding contained id mentioned in the command.
Docker volume
This command creates a volume so that the docker container can use it to store data.
Docker logout
This command will log you out of the docker hub.
1. Components of Docker and its Brief Summary?
Docker client and server: Docker Engine is installed on the server side and the client side just consist of the Command Line Interface used for issuing commands to Docker Engine.
Docker image: A Docker image is a file used to execute code in a Docker container.
Docker registry: A Docker registry is a storage and distribution system for named Docker images.
Docker container: A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application.
2. What is the difference between Docker pause and unpause?
If we want to pause the processes running inside the container, we use the “docker pause” command. To unpause the container, use “docker unpause” command.
3. What is the difference between Docker stop and kill?
The Docker Stop command stops the container gracefully and provides a safe way out.
If a Docker Stop command fails to terminate a process within the specified timeout, the Docker issues a kill command implicitly and immediately.
4. What is the difference between Docker exec and attach?
Docker exec executes a new command or create a new process in the container’s environment.
Docker attach basically used to attach your host systems standard input, standard output and standard error with that of a container.
5. List of Dockerfile instructions and its Brief Summary?
There are a variety of Dockerfile instructions we can put in our Dockerfile.
These includes:
6. What is the difference between CMD vs Entrypoint.
7. List of 20 Docker commands and its use cases with example?
Docker ps: This command is used to list all the running containers in the background.
Docker ps -a: This command is used to know the details of all the running, stopped, or exited containers.
Docker version: We usually start by finding the installed version of docker that we are working on.
Docker pull: As the name suggests, this command pulls a specific image from the Docker Hub. All you have to do is use the command ‘docker pull’ along with the name of the image. Here is an example of pulling an image without using the tag.
Docker run: This command is used to create a container from an image.
Docker stop: The ‘docker stop’ command stops a container using the container name or its id.
Docker restart: This command is used to restart the stopped container. It is recommended to use this after rebooting the system.
Docker kill:This command is used to stop the container immediately by killing its execution. While the ‘docker stop’ command helps shut down the container in its own time, the ‘docker kill’ command stops it at once.
Docker login:This command helps you to log into your docker hub. As you try to log in, you will be asked to give your docker hub credentials.
Docker network:The ‘docker network’ command is used to know the details of the list of networks in the cluster.
Docker-compose down: You need to stop all services declared in a docker-compose file.
Docker-compose logs: Your service crashed on launch and you want to know why.
Docker-compose stop: You want to stop your container by service name or container name.
Docker-compose restart: You want to restart a container with the service name or container name.
Docker-compose exec: You want to access inside the launched container and execute something, similar with docker exec.
Docker-compose down: You need to stop all services declared in a docker-compose file.
Docker rmi: You need more space on your disk.