Monday, November 20, 2023

Docker 6

 Let us revise the previous sessions once again. 


root@ip-172-31-15-245:~# docker images

REPOSITORY    TAG       IMAGE ID       CREATED        SIZE

nginx         latest    c20060033e06   2 weeks ago    187MB

ubuntu        18.04     f9a80a55f492   5 months ago   63.2MB

hello-world   latest    9c7a54a9a43c   6 months ago   13.3kB

root@ip-172-31-15-245:~# docker pull alpine

Using default tag: latest

latest: Pulling from library/alpine

96526aa774ef: Pull complete

Digest: sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978

Status: Downloaded newer image for alpine:latest

docker.io/library/alpine:latest

root@ip-172-31-15-245:~# docker images

REPOSITORY    TAG       IMAGE ID       CREATED        SIZE

nginx         latest    c20060033e06   2 weeks ago    187MB

alpine        latest    8ca4688f4f35   7 weeks ago    7.34MB

ubuntu        18.04     f9a80a55f492   5 months ago   63.2MB

hello-world   latest    9c7a54a9a43c   6 months ago   13.3kB

root@ip-172-31-15-245:~#


























To check what all the containers are running, then we use the below command

docker ps or docker container ls
docker ps -a







Assume that in case if i want to run the container busy box. then i go with the below command


root@ip-172-31-15-245:~# docker run busybox:latest
root@ip-172-31-15-245:~#













In the above screenshot, we can see that we have not assign any names to it. But we can assign own name by using the below command

 docker run --name con1 busybox:latest sh









From ,  the above screen shot you can see that i have defined the name as con1.


If you want to stop then you can use the below command


root@ip-172-31-15-245:~# docker stop con2
con2


Difference between pull and run and run command








When we run single command, it will check if that image is available or not locally.  If not available it will go and pull the image and then download and run.









 docker run -dit --name test123 ubunto:18.04, to give name  you need to run this command.









This, time i am not going to using the pull command. I am going to use the Run Command.


I am going to Run the different Image that is nginx.

docker run -idt --name abc123 -p 80:80 nginx-->If the image is not available
then it goes and pulls that image. 
If available locally, then it wont pull that image















If we want to stop any one of the container, then i can go with the below command










docker stop test123

If i go with docker info command

Total no of containers created stopped and running 
































root@ip-172-31-15-245:~# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                               NAMES
6466490db8e3   nginx     "/docker-entrypoint.…"   13 minutes ago   Up 13 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp   abc123
root@ip-172-31-15-245:~#


Here, you can see the port no is 80

Now, i want to run the above container outside using port Number.

Get the ip address by running the below command

root@ip-172-31-15-245:~# hostname -i


Now, we need to login into the AWS Account, which we created , and browse with the public ip address

In the AWS Account, you can see the below screen






















Never Expose private IPto others, than people might krack and hack it

Now click on the security Group Link as shown below














Now, click on the Edit the Inbound Rules























Go at the bottom and add the new port Number












Now, browse the url with the public address and give the port name as 80 to it.






Now, i am going to stop that with the container id by using the below command

docker stop 6466490db8e3







Now, if i go and browse the nginx home page. 

I will get an error page saying that this site cant be reached. Because that is stop you wont be able o browse it
















Now, i am going to start it again by using the below command



root@ip-172-31-15-245:~# docker start abc123
abc123











Now, again you browse the nginx page, you will be able to load it












Now, i want to check the memory of the container. For that we have a command call as 

docker stats

You can give the container id or name 
docker stats abc123 
or
docker stats containerid













Once we run docker stats cmd, we can see the cpu usage, memory and other things

 We can also restart the container by using the below command

docker restart container id or name


root@ip-172-31-15-245:~# docker restart abc123
abc123
root@ip-172-31-15-245:~#


To remove the container we basically use linux cmd that is 
docker rm name or container id

First we need to stop it before deleting it. 








To remove image use the below command 
docker rmi name or id




Now, i want to go to the folder path. 
use the below cmdls will list out all the folder inside that folder







cat is the linux command used to open the file. Now, I am going to open the repostiores.json file










 











Docker 5

Docker for Windows

Docker has out-of-the-box support for Windows, but you need to have the following configuration in order to install Docker for Windows.

System Requirements

Windows OSWindows 10 64 bit
Memory2 GB RAM (recommended)

You can download Docker for Windows from − https://docs.docker.com/get-docker/


  1. Double-click Docker Desktop Installer.exe to run the installer.

  2. When prompted, ensure the Use WSL 2 instead of Hyper-V option on the Configuration page is selected or not depending on your choice of backend.

    If your system only supports one of the two options, you will not be able to select which backend to use.

  3. Follow the instructions on the installation wizard to authorize the installer and proceed with the install.

  4. When the installation is successful, select Close to complete the installation process.

  5. If your admin account is different to your user account, you must add the user to the docker-users group. Run Computer Management as an administrator and navigate to Local Users and Groups > Groups > docker-users. Right-click to add the user to the group. Sign out and sign back in for the changes to take effect.


Working with Docker Toolbox

Let’s now look at how Docker Toolbox can be used to work with Docker containers on Windows. The first step is to launch the Docker Toolbox application for which the shortcut is created on the desktop when the installation of Docker toolbox is carried out.

Quickstart Terminal

Next, you will see the configuration being carried out when Docker toolbox is launched.

Docker Toolbox Terminal

Once done, you will see Docker configured and launched. You will get an interactive shell for Docker.

Interactive Shell

To test that Docker runs properly, we can use the Docker run command to download and run a simple HelloWorld Docker container.

sudo docker run hello-world


This command will download the hello-world image, if it is not already present, and run the hello-world as a container.

Output

When we run the above command, we will get the following result −

Docker Container


Docker 4

 Please go through part 6 before reading this article

https://dotnetbyudayrajakonda.blogspot.com/2023/11/ms-azure-part-6.html

We have a other command called as docker info




Explanation

This command will give all the information.

We have a client and server options here. 

By default you can see the client values as shown below
 Context:    default
 Debug Mode: false

Server Values

Containers: How many containers are currently running.
        Running: How many container are in the Running State
        Paused: How many containers are in the paused State
        Stopped: How many containers are in the stopped State

Running instance of an Image is nothing but Container
Only standard which is supported is Image Format

Server Version: It is nothing but the Docker Version(which we can also get from docker -v)
Below is the screen shot






Storage Driver: It will display information about storage driver. The below are the properties of Storage Drivers.

    Backing FileSystem : extfs-->It is basically a Linux file system. As we have installed ubuntu it is nothing but the Linux   

    Support d Type
    Using metacopy: false
    Native Overlay Diff: true
    userxattr: false


Logging Driver: All logs are by default kept in a json format. It also supports other formats as well.

Dockers has few plugins those are 

    Volume: local
    Network: bridge host ipvlan macvlan null overlay
    Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk         syslog


bridge is the default network

host: Client Network,

ipvlan : It is similar to mac address

null: It is stand alone network, No one can use this network.

overlay: When you create cluster based env, in that case we need this.

Logs:
You can create logs in other tools such as splunk, etc

Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog

    fluentd --> It is collect all the logs, and send to the central server.

We have got few inbuilt security options in deckor those are 
           apparmor
           seccomp
           Profile: builtin

We will discuss on all this options, with the examples.

Let now, you might have understand but  the installation and the basics command commands.

As discuss in the previous article, to pull the image with the version , below is the example command
# docker pull ubuntu:18.04















Tag is nothing but the version.

In docker everything will be 12 digit only

























To run, you  can use the below command

docker run -d -i -t 
or 
docker run -idt

Note: it can be in any order.

root@ip-172-31-15-245:~# docker run -idt --name test123

Docker 3

Please go through part 5 before reading this article

https://dotnetbyudayrajakonda.blogspot.com/2023/11/ms-azure-part-5.html

Let me create a new container.

Before that let me pull the image of nginx by running the below command

docker pull nginx








Here Digest sha is basically a nasa format

To check all the images, which are downloaded till Now. use the below command 





What all the container we are running we can get by using the below command

Listing of Containers

docker ps(print status)-

One can list all of the containers on the machine via the docker ps command. This command is used to return the currently running containers.

Return Value

The output will show the currently running containers.

Use  docker ps -all command to check all the containers which are running, stopped and paused.


docker ps -a

This command is used to list all of the containers on the system





Now, we need to start the container. Use the below command

root@ip-172-31-15-245:~# docker run -itd --name test123 nginx:latest

In the above command you can see that i have given a name test123

nginx:latest- means it will take the latest one. We can also give the version numbers as well.






To stop the container use the below command

docker stop test123





Now, i want to start the command, then use the below command

doctor start test123




Sunday, November 19, 2023

Docker 2

Please follows the Part1, Part2, Part 3, Part 4  before reading this.

https://dotnetbyudayrajakonda.blogspot.com/2023/11/introduction-to-azure-dev-ops.html

https://dotnetbyudayrajakonda.blogspot.com/2023/11/ms-azure-part-2.html

https://dotnetbyudayrajakonda.blogspot.com/2023/11/ms-azure-part-3.html

https://dotnetbyudayrajakonda.blogspot.com/2023/11/ms-azure-part-4.html

Now, we need to switch the user. So that i want to install Docker with root user. So i am going to run the below command

ubuntu@ip-172-31-15-245:~$ sudo su-









  1. $ apt-get update  









Now, I am going to run the next command

apt-get install docker.io -y

















Command to clear the screen is clear

history is the command , which will tell you what all the command which have been run  today.

Example














To check if the docker is installed or not, below is the command

root@ip-172-31-15-245:~# docker --version
Docker version 24.0.5, build 24.0.5-0ubuntu1~20.04.1
root@ip-172-31-15-245:~#






To check the status of instance, which we have created in the aws cloud with the name docker. Below is the command to check the status

service docker status














Note:
dockerd is docker daemon


If, it is not started, then you say
service docker start

If you type the command as 
docker version
Then you will be able to see the client and the service


























We can also use 
root@ip-172-31-15-245:~# docker -v
Docker version 24.0.5, build 24.0.5-0ubuntu1~20.04.1
root@ip-172-31-15-245:~#

Next, go to the site


Now, you need to register yourself


After registering yourself, login into that  and the below screen gets displayed and search for hello world to test.












If every thing is working fine, then we will get the output as hello world.  To make sure that set up is done properly. let me run that command
















In the above screen shot, you can see that it is not able to find the image 
so it is pulling from the library
once pulling from library is completed. it is going to download that image



Hello from Docker!
This message shows that your installation appears to be working correctly.


Set up is done successfully.

Displaying Docker Images

To see the list of Docker images on the system, you can issue the following command.

Return Value

The output will provide the list of images on the system.


docker image ls or docker images









You can also use the below command  
docker ps -all









Kubernetes

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