0% found this document useful (0 votes)
8 views10 pages

Docker Images vs Containers Guide

Docker_Image_Vs_Docker_Container

Uploaded by

carreirajuan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views10 pages

Docker Images vs Containers Guide

Docker_Image_Vs_Docker_Container

Uploaded by

carreirajuan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AJAY .

net info

Docker Image
Vs
Docker Container

ajay patel
@iamajaypatel
AJAY .net info

DOCKER

Images Containers

Templates for The running instance


containers of Image.

Contains code, Mutiple container


dependencies, can be created
runtime based on one image.

Layer-based, Read and Write


read-only. access. Data is lost
on shutdown.

ajay patel
@iamajaypatel
SWIPE
AJAY .net info

One Image, Container


Multiple Containers
Running .Net App

Image
Container
.Net App Code
Running .Net App
.Net SDK/Runtime

Container

Running .Net App

ajay patel
@iamajaypatel
SWIPE
AJAY .net info

How to get an Image?

Use an existing, pre-built


Create your custom image
image

From Write your own


Dockerfile
Docker Hub

Microsoft Container
Registry

Other private registry

ajay patel
@iamajaypatel
SWIPE
AJAY .net info

1 Downloading Images:
The docker pull command is used to
download an image from the repository so
that it is available locally.

docker pull imagename:tag


ex: docker pull node
if you don’t specify tag, it will pull latest
image.

docker run imagename:tag


docker run download an image from
repository if it is not available locally and
create and start the container.

ajay patel
@iamajaypatel
SWIPE
AJAY .net info

2 Create custom Image:

docker build -t name:tag .

Dockerfile

ENTRYPOINT [”dotnet”,”example.dll”]

COPY . .

WORKDIR /app

Base image from docker hub/ microsoft


registry

ajay patel
@iamajaypatel SWIPE
AJAY .net info

Container based on Image

Container

Thin container layer


read-write

Instruction:3/Layer 3
Image
Instruction:2/Layer 2 read-only
Instruction:1/Layer 1

docker run imagename:tag

ajay patel
@iamajaypatel
SWIPE
AJAY .net info

Key Commands for image:

Build an image: docker build -t name:tag .

Inspect an image: docker inspect name/id

Remove an image: docker rmi name/id

Remove all images: docker image prune

Pull an image: docker pull name:tag

NOTE: docker image prune will remove only


untagged images. If you want to remove tagged
images as well add -a with command.

ajay patel
@iamajaypatel
SWIPE
AJAY .net info

Key Commands for container:

docker create imagename: Create


new container.
docker run imagename: Create and
start new container based on image.
docker stop containername: Stop a
running container.
docker start containername: Start a
stopped container.

docker rm containername: Remove


specified container.

docker container prune: Remove all


containers.

ajay patel
@iamajaypatel
SWIPE
AJAY

Knowledge is
contagious,
let’s spread it!

DO YOU LIKE THIS POST?

REPOST IT!

ajay patel
@iamajaypatel .net info

You might also like