Friday, 11 September 2020

LINUX - HOW TO DELETE A USER IN LINUX

LINUX - HOW TO DELETE A USER IN LINUX

 

Please find the command to delete a user in linux:-

 Command :- sudo userdel john


LINUX - HOW TO ADD A USER IN LINUX

LINUX - HOW TO ADD A USER IN LINUX

 

Please find the command to add a user in linux:-

 Command :- sudo useradd john

 

In the above example, we have created a user john.

Friday, 26 June 2020

DOCKER - HOW TO REMOVE A DOCKER IMAGE FROM OUR HOST

HOW TO REMOVE A DOCKER IMAGE FROM OUR HOST


In order to remove a docker image from our system:-

run the command :- docker rmi (Name of the Image)

 

  

 

In my example, I have deleted the image - docker/whalesay which I downloaded earlier.

 

Note:- Before deleting an image, please make sure that no container is using that image. 

 

You need to stop and delete all the containers using this image, before deleting this image.

DOCKER - HOW TO SEE A LIST OF IMAGES PRESENT ON THE HOST

HOW TO SEE A LIST OF IMAGES PRESENT ON THE HOST

 

 In order to see the list of all the docker images and their sizes, run the command - docker images

 

 

 

DOCKER - HOW TO REMOVE A CONTAINER PERMERANTLY

HOW TO REMOVE A CONTAINER PERMANENTLY


If we want to remove the docker container permanently, 

run the command - docker rm (Provide the name of the container or ID)


In the below example, we see that we have 2 exited containers


Now we will delete the 2 exited comtainers:- flamboyant_hodgkin and sleepy_swirles

We can verify if the both the containers are deleted, by running 
the command - docker ps -a

DOCKER - HOW TO STOP A RUNNING CONTAINER

HOW TO STOP A RUNNING CONTAINER

 

 If we want to stop the running container running on our system, 

run the command :- docker stop (Provide the container name or container id )

We can get the details of the container by running the command - docker ps -a

 

 

DOCKER - HOW TO SEE RUNNING DOCKER CONTAINERS

HOW TO SEE RUNNING DOCKER CONTAINERS

 

 In order to list all the docker containers, run the command - docker ps


 

Now if we want to see the previous containers which may be stopped or exited, you need

to run the below command:- docker ps -a.  Hence we see that we ran a previous container 

by the name - whalesay.


Wednesday, 24 June 2020

DOCKER - HOW TO DOWNLOAD DOCKER IMAGE FROM DOCKER HUB

DOCKER - HOW TO DOWNLOAD DOCKER IMAGE FROM DOCKER HUB


In the below example, we will download the docker image - whalesay from Docker Hub and will run it on the local system. In order to do that run the command:- 

docker run docker/whalesay cowsay Hello World!
 
This would download the docker image - whalesay from Docker Hub and will 
display a message - Hello World! as shown below. 


 
 

DOCKER - How to login into Docker Hub from your local system

How to login into Docker Hub from your local system?


On your local system, type in the command:- docker login

This would prompt you to enter the username and password.






DOCKER - How to start the Docker Daemon

How to start the Docker Daemon?


In order to start the docker service on the  host, run the command:- sudo systemctl start docker

 


DOCKER - How to install Docker

How to install Docker?

 

1)  Go to the URL:- https://get.docker.com/

 

2) Copy the command and run it on the local system:-

curl -fsSL https://get.docker.com -o get-docker.sh

This command will get the script - get-docker.sh from the above URL and will deposit it to the local system. 

 

 

 

3) Now to run the shell script, run the command:- sh get-docker.sh which will start the installation of docker on the local system.

 

In this example, I am running the command with the root user. If you like to use Docker as a non root user, then we should add our user to the docker group with something like:-

sudo usermod -aG docker youruser

 



Once the docker is installed, you can check the version by the command:- docker version