Wednesday, November 22, 2023

Docker 8

 Read the previous articles.

In the previous article, i have committed my changes . So now i want to login and check . In the previous i have created login credentials in the https://hub.docker.com/ 
























To make it  visible to the public


















Revise the previous articles 

1 step : pull the image

docker pull redis






2 step
Run the below command
docker run  -it redis bash












Step 3

docker exec -it redis123 bash






Let me go inside that directory and create a sample text and save with sample.txt name

Step 4:
root@befffa2a3fd7:/data# mkdir demo123

Step 5









Step 6

echo "test container">sample.txt



























Next step is we need to run the exit command.









Now, the above commit will be saved in the docker images










Next step in login to docker hub by running the below command














Now, we need to push the changes to the docker hub of your login. So that you will be able to see your changes in the hub.






































Make that as public
Now, i am going to delete the container


















Now, let me delete all the images 

















Now, i am pulling that image from hub by using the below command

docker run -idt --name testabc uday9287/redis:1.0



Tuesday, November 21, 2023

Docker 7

 Please read the previous articles related to azure 





From the above image , you can see the list of images complete details inside that









Now, i want to list out all the container details








Now, from the above screenshot you can compare the ids.

You can forcefully delete the container instead of stopping it. By using the below command

docker rm -f containerId or Name

Committing Changes to Docker

Running a Container

Running of containers is managed with the Docker run command. To run a container in an interactive mode, first launch the Docker container.

Syntax:    sudo docker run –it centos /bin/bash 

Now, let us exec the command using bash

docker exec -it test123 bash







From the above image you can see once you have runned the command, It has changed the root ip to the container id.

Type ls command to list the files inside it














Let me run the below command to create a directory inside that

root@83059965016c:/# mkdir demo123

Let me go inside that directory and create a sample text and save with sample.txt name



root@83059965016c:/demo123# echo "This is my tes file">sample.txt

root@83059965016c:/demo123# ls













root@83059965016c:/demo123# exit

Now, if i click on exit i am going to come back again to root folder. 












Now, i want to commit this changes

Still am changes are in the temp memory. That is not permanent.  Now let us go back to AWS Account and check.







Now, we need to give read and write permissions to that file first. We can also install package as well.











Try to install apache2 by running the below command

 apt install apache2 -y

Try to install git by running the below command 






To check if the git is installed, use the below command

root@83059965016c:/# git -v
git version 2.39.2

We can also go inside the folder  by using the below commands

root@83059965016c:/# ls/usr/share/

Finally exit the command n then use commit command

docker commit containerid or name






The above  commit will be saved in the docker images.
if we check








Few more Commands

docker images -q

This command is used to return only the Image ID’s of the images.














docker inspect

This command is used see the details of an image or container.

Syntax

docker inspect imagename












docker history

With this command, you can see all the commands that were run with an image via a container.

docker history ImageID 



docker stop

This command is used to stop a running container.

Syntax

docker stop ContainerID 

docker rm

This command is used to delete a container.

Syntax

docker rm ContainerID 

docker stats

This command is used to provide the statistics of a running container.

docker stats ContainerID

docker pause

This command is used to pause the processes in a running container.

docker pause ContainerID 




docker unpause

This command is used to unpause the processes in a running container.




docker kill

This command is used to kill the processes in a running container.

docker kill ContainerID



Docker – Container Lifecycle

The following illustration explains the entire lifecycle of a Docker container.

Container Lifecycle

  • Initially, the Docker container will be in the created state.

  • Then the Docker container goes into the running state when the Docker run command is used.

  • The Docker kill command is used to kill an existing Docker container.

  • The Docker pause command is used to pause an existing Docker container.

  • The Docker stop command is used to pause an existing Docker container.

  • The Docker run command is used to put a container back from a stopped state to a running state


docker container prune:

This is the command, which will delete all the exited containers.


What is difference between docker run and docker start?
Docker start command is used to start any stopped container. Docker run command is a combination of creating and start as it creates a new container and starts it immediately.


What is difference between docker attach and Docker exec?
This is basically the major difference between exec and attach. When you run an exec, it will basically spins up a new process inside the container whereas attach basically lets you attach to an existing process inside the container

Differences Between Docker Run and Docker Exec

The docker run command creates and starts a new container from an image, while the docker exec command interacts with an already running container

Example of Docker Attach



















Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...