- Problem of environment separation for applications.
- Problem of resource sharing.
- Problem of portability.
- Problem of easy scalability.
- Problem of doing all this in a secured manner.
- Virtual Machines or VM
- Docker
- Advantages of Docker
- All container share same kernel - thus storages is saved.
- Container boot time is less.
- Support for version control.
- Multiple container can start from single docker image and communicate.
- Images can be built on top of another.
- Install docker.
- Initiate docker.
- Check if it's working by
docker version
ordocker-compose version
.
- Images are blueprint and container their instance.
- To create image, we need to write instruction in
Dockerfile
and to create the container run the image.
-
Dockerfile describes how to build the image,
docker-compose
is used to run containers fromdocker-compose.yaml
. -
docker-compose.yaml
can have reference to Dockerfile but not the other way around. -
Sample
Dockerfile
FROM alpine:latest RUN apk update && \ apk add curl && \ apk add git && \ apk add vim
Sample
docker-compose.yaml
version: "3.9" services: web: build: . ports: - "8000:5000" redis: image: "redis:alpine"