This repository explain all about the docker operations and its use cases with good idea on how to create an image file. Have a look at docker website. One of the biggest use of docker in development is portable application development and helping to provide the same environment throughout. There are three most important technologies i.e git, docker and kubernetes. Hence it is very important to learn docker. It has a smooth integration and also provide a virtual machine without any hassles and is much smaller in size.
There is always the issues of compatability, dependency, issues of long setup time and different environments while developing an application with developers across divisions. We need four different services for building an application : Hardware, OS, dependencies and libraries. We need an OS that is compatible with all these four steps and hence its becomes an issue for new developers. There are differences of versions as well. It always creates an issue. Owing to these reasons docker was introduced in first place. Docker config file will help you define the boundaries of your environment. No one can also see your source code with docker image, hence there will be a level of abstraction.
Container is a box that contains a running application. It have its own machine name, address and its own drive. All the containers running on your system use the same OS kernel. Hence container is an isolated environment on the same OS kernel. Docker uses Alexsi containers. One cannot run a Windows OS container on linux kernel. It requires Windows OS host. One interesting question can be than how we are able to run a linux container on windows. It basically creates a linux VM which runs on windows. Windows will assign a linus VM to it and inside this VM the container based on linux will run.
Docker provides a platform to run containers on the OS kernel provided by your hardware whereas in Virtual machines, they run on the OS and furthe rcontains containers within them which are running on the OS of VMs. Hence resource utilisation with docker is less than the resource utilisation by Virtual Machines.
Image is a source code, libraries, dependencies and other stuff whic define the container and needed for application to run. Image is just a template with set of instruction. You need an image to build a docker container. One moves from dockerfile -> Image -> Container. Dockerfile creates an image.
- Docker Client
- Docker Server : Underlying service that helps docker.
- Docker Images : All files required to run a dockerised container
- Docker Container
Download and install docker desktop. It can be found on the website of docker for all the versions of OS you require. Open the docker desktop.
To check whether docker is running or not. Just open the command prompt and type the command docker. You will get something of this sort.
C:\xxxx\yyyyy>docker
C:\Users\rohan_sharma1>docker --version Docker version 20.10.6, build 370c289
Follow this website : https://docs.docker.com/engine/install/ubuntu/
- Stop a running docker container : docker stop <container_id>
- Run a docker image : docker run --publish 8000:8000 node-docker
- See all running containers : docker ps -a
- go inside a container : docker exec -it <container_id> sh
- remove all containers which stopped: docker system rm -a
- Run a container (first it will look the image in local whether this is available or not and if not found will download this image form docker hub): docker run <image_name>
- list all the image : docker images
- remove a particular container : docker rm <container_id>
- Remove image : docker rmi <image_name>
- Pulling the image without running : docker pull <image_name>
It is a tool to define and share multi container applications. Lets say there are four different containers one is running the flask app, one is running the Cassandra database, one is running Redis messaging service, one is running orchestration service Ansible. If you are not using docker compose for this you will be running all the images separately and bring multiple containers up. But with docker compose yaml file we can bring all the containers up simultaneously.
This repository is a very concrete example on use of docker compose.