DOCKER

VM

VIRTUAL MACHINES

Virtual machines (VMs) are an abstraction of physical hardware turning one server into many servers. The hypervisor allows multiple VMs to run on a single machine. Each VM includes a full copy of an operating system, one or more apps, necessary binaries and libraries - taking up tens of GBs. VMs can also be slow to boot.

Container

 

CONTAINERS

Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VMs (container images are typically tens of MBs in size), and start almost instantly.

Installing Docker 

  • https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac
  • install Docker.dmg
  • Docker is running as a Demon

Starting a Single Container

 

docker run -d -p 80:80 --name webserver nginx
  • pulling and starting an instance of an image as a container
  • running container in detached mode
  • opening container port on host port

list conatiners

(sudo) docker ps [OPTIONS]

docker exec -ti docker_conatiner_name OR docker_container_ID

Layered File System

Dockerfile

  • Docker can build images automatically by reading the instructions from a Dockerfile.
  • The docker build command builds an image from a Dockerfile.
  • You use the -f flag with docker build to point to a Dockerfile anywhere in your file system.
  • You can specify a repository and tag at which to save the new image if the build succeeds.
  • To tag the image into multiple repositories after the build, add multiple -t parameters when you run the build command:

Example

Docker-Compose

  • Compose is a tool for defining and running multi-container Docker applications
  • With Compose, you use a Compose file to configure your application’s services

DEMO !!!

DOCKER

By Nikunj Parmar

DOCKER

  • 1,857