Docker, Containerization vs virtualization & Installing Docker, Docker Terminologies

Docker is a containerization tool.

Virtualization — Fixed hardware allocation.

Containerization – No Fixed Hardware

Process isolation ( Dependency in os is removed )

+++++++++++++++++++++++++

In comparison to the traditional virtualization functionalities of hypervisors,
Docker containers eliminate the need for a separate guest operating system for every new virtual machine.

Docker implements a high-level API to provide lightweight containers that run processes in isolation.

A Docker container enables rapid deployment with minimum run-time requirements. It also ensures better management and simplified portability.
This helps developers and operations team in rapid deployment of an application.

+++++++++++++++++++++++++
Create Ubuntu Machine on AWS
All Traffic – anywhere

Connect using git bash

https://get.docker.com/

Go to Root Account
$ sudo su –

curl -fsSL https://get.docker.com -o get-docker.sh ( this will download shell script in the machine)

sh get-docker.sh ( This will execute the shell script, which will install docker )

How to check the docker is installed or not

docker –version

We should be comformatable with four terms
1) Docker Images
Combinations of binaries / libraries which are necessary for one software application.

2) Docker Containers
When image is executed comes into running condition, it is called container.

3) Docker Host
Machine on which docker is installed, is called as Docker host.

4) Docker Client
Terminal used to run docker run commands ( Git bash )

On linux machine, git bash will work like docker client.

+++++++++++

Docker Commands

Working on Images

1 To download a docker image
docker pull image_name

2 To see the list of docker images
docker image ls
(or)
docker images

3 To delete a docker image from docker host
docker rmi image_name/image_id

4) To upload a docker image into docker hub
docker push image_name

5) To tag an image
docker tag image_name ipaddress_of_local_registry:5000/image_name

6) To build an image from a customised container
docker commit container_name/container_id new_image_name

7) To create an image from docker file
docker build -t new_image_name

8) To search for a docker image
docker search image_name

9) To delete all images that are not attached to containers
docker system prune -a

++++++++++++++++++++++++++++++++++++++++++++++

Working on containers

10) To see the list of all running continers
docker container ls

11) To see the list of running and stopped containers
docker ps -a

12) To start a container
docker start container_name/container_id

13) To stop a running container
docker stop container_name/container_id

14) To restart a running container
docker restart container_name/container_id
To restart after 10 seconds
docker restart -t 10 container_name/container_id

15) To delete a stopped container
docker rm container_name/container_id

16) To delete a running container
docker rm -f container_name/container id

17) To stop all running containers
docker stop $(docker ps -aq)

18) To restart all containers
docker restart $(docker ps -aq)

19) To remove all stopped containers
docker rm $(docker ps -aq)

20) To remove all contianers(running and stopped)
docker rm -f $(docker ps -aq)

21) To see the logs generated by a container
docker logs container_name/container_id

22) To see the ports used by a container
docker port container_name/container_id

23) To get detailed info about a container
docker inspect container_name/container_id

24) To go into the shell of a running contianer which is moved into background
docker attach container_name/container id

25) To execute anycommand in a container
docker exec -it container_name/container_id command
Eg: To launch the bash shell in a contianer
docker exec -it container_name/container_id bash

26) To create a container from a docker image ( imp )
docker run image_name

++++++++++++++++++++++++++++++++++++++++++++++++

Run command options

-it for opening an interactive terminal in a container

–name Used for giving a name to a container

-d Used for running the container in detached mode as a background process

-e Used for passing environment varaibles to the container

-p Used for port mapping between port of container with the dockerhost port.

-P Used for automatic port mapping ie, it will map the internal port of the container
with some port on host machine.
This host port will be some number greater than 30000

-v Used for attaching a volume to the container

–volume-from Used for sharing volume between containers

–network Used to run the contianer on a specific network
–link Used for linking the container for creating a multi container architecture

–memory Used to specify the maximum amount of ram that the container can use

++++++++++++++++++++++++++++++++++++++++++++++++++=

docker images ( There are no images )

To download tomcat image

docker pull tomee

docker images

docker pull ubuntu

If you do not specify the version, by default, we get latest version

I want to download jenkins

docker pull jenkins


docker run –name c1 -p 7070:8080 tomee

http://public-ip:7070

Lets remove the container
docker container ls

docker stop c1

docker rm -f c1

docker run –name mytomcat -p 7070:8080 -d tomee

Docker run –name myjenkins -p 9090:8080

Leave a Comment

MFH DevOps Consultation Services

Add Few lines about the company here

Contact

MFH Devops Consulation
#4-72-1/1. 1st Floor, Beach Road Lawson’s Bay Colony, Near Shanti Ashram, Opp. Bharat Petroleum, Visakhapatnam, Andhra Pradesh – 530017