- What is Docker
- Docker is a virtualization Software developed to simply the process of developing, deploying and managing applications. It does this by using two things namely, image and container
- Docker Vs VM
- Docker virtualizes the application layer, meaning it doesn’t have its own kernel
- Where as a VM virtualizes the whole OS including the kernel.
- So basically VM creates a completely brand new OS with its own kernel on top of the native OS. Where as docker uses the existing kernel and only creates it own application layer.
- Image referenced from here
- What is an Image
- An Image is a template that is used to spin up containers
- Ex: Ubuntu, Redis
- An Image is a template that is used to spin up containers
- What is Container
- A container is a running instance of an image. It is an environment in which the images run.
- Image vs Container
- Image can be thought of as the application and a container as an environment in which the image runs. The container has all the configuration files, dependencies and other necessary parts for the application to run.
- Registry
- A Docker registry stores the docker images
- Docker Hub is a public registry and that is where docker looks for images by default
- A Docker registry stores the docker images
- We can create our own images by defining a file called the DockerFile
- What happens inside of docker
- From a client system a call is made saying something like docker pull, that request is send to the docker daemon, which inturn goes to the docker registry and searches for that image and downloads that to the system.
- So we execute all of our instructions or commands inside of a software called the docker client. The client talks to the docker daemon, which does all the operations.
- In order to get the docker daemon and docker client we can use a piece of software called the docker desktop, which packages both of those into a single application for us to use in our system.
- Basic Commands
- docker ps
- Lists the running containers
- docker ps -a
- Lists all the running as well as stopped containers
- Lists the running containers
- docker pull <Image Name>
- Pulls/Downloads an image to system
- docker start <Container Id>
- Starts an existing docker container
- docker run <Image Name>
- Pulls and starts the container
- docker run -d <Image Name>
- Run the container in detached mode
- docker run -d <Image Name>
- docker run redis:4.0
- docker run —name redis redis:4.0
- Pulls and starts the container
- docker stop <Container Id>
- Stops a running container
- docker run -p5400:6379 redis
- docker run -p<Host port>:<Container Source Port> <Image Name>
- docker images
- docker ps
- Debugging inside container
- docker logs <Container Id>
- docker exec -it <Container Id> /bin/bash
- Docker File commands
- FROM
- COPY
- WORKDIR
- RUN
- CMD
- .dockerignore
- docker build -t <Image Name> .
docker build -t angular-app:1.0 .
docker run -d -p 8888:80 --name=angular-app angular-app:1.0