Virtualization Flashcards

1
Q

What is virtual Machine and Virtualisation?

A

https://www.redhat.com/en/topics/virtualization/what-is-virtualization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Difference between Docker containers and VMs

A

https: //www.youtube.com/watch?v=TvnZTi_gaNc
https: //blog.cherryservers.com/docker-containers-vs.-virtual-machines-know-the-differences#:~:text=The%20Docker%20container%20sits%20on,the%20components%20being%20read%2Donly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Docker Terminologies

A

Images - The blueprints of our application which form the basis of containers. In the demo above, we used the docker pull command to download the busybox image.
Containers - Created from Docker images and run the actual application. We create a container using docker run which we did using the busybox image that we downloaded. A list of running containers can be seen using the docker ps command.
Docker Daemon - The background service running on the host that manages building, running and distributing Docker containers. The daemon is the process that runs in the operating system which clients talk to.
Docker Client - The command line tool that allows the user to interact with the daemon. More generally, there can be other forms of clients too - such as Kitematic which provide a GUI to the users.
Docker Hub - A registry of Docker images. You can think of the registry as a directory of all available Docker images. If required, one can host their own Docker registries and can use them for pulling images.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Docker commands

A

docker ps - list all images
docker pull
docker run
docker run -it sh = interactive mode
docker run –help
docker ps -a
docker rm 305297d7a235(CONTAINERiD)
docker container prune = remove all stopped containers
docker rm $(docker ps -a -q -f status=exited) [Remove docker containers which have status as exited – q stands for numeric ids to be returned, -f stands for filter to be applied]
docker run ImageName –rm
docker run -d -P –name static-site prakhar1989/static-site ( -d stands for it will detach terminal - even if you close terminal, it wont get closed.. )
-P will publish all exposed ports to random ports and finally –name corresponds to a name we want to give

docker port static-site
docker run -p 8888:80 prakhar1989/static-site

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Types of images:

A

Base images are images that have no parent image, usually images with an OS like ubuntu, busybox or debian.

Child images are images that build on base images and add additional functionality.

Then there are official and user images, which can be both base and child images.

Official images are images that are officially maintained and supported by the folks at Docker. These are typically one word long. In the list of images above, the python, ubuntu, busybox and hello-world images are official images.

User images are images created and shared by users like you and me. They build on base images and add additional functionality. Typically, these are formatted as user/image-name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Dockerfile for python application

A

FROM python:3

# set a directory for the app
WORKDIR /usr/src/app
# copy all the files to the container
COPY . .
# install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# define the port number the container should expose
EXPOSE 5000
# run the command
CMD ["python", "./app.py"]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

building image

A

docker build -t yourusername/catnip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

docker run -p 8888:5000 yourusername/catnip

A

The command we just ran used port 5000 for the server inside the container and exposed this externally on port 8888. Head over to the URL with port 8888, where your app should be live.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

DOCKER Repository and DOcker Registry difference

Docker hub is a registry

A

A Docker repository is where you can store 1 or more versions of a specific Docker image. An image can have 1 or more versions (tags).
A Docker image can be compared to a git repo. A git repo can be hosted inside of a GitHub repository, but it could also be hosted on Gitlab, BitBucket or your own git repo hosting service. It could also sit on your development box and not be hosted anywhere.

The same goes for a Docker image. You can choose to not push it anywhere, but you could also push it to the Docker Hub which is both a public and private service for hosting Docker repositories. There are other third party repository hosting services too.

The thing to remember here is a Docker repository is a place for you to publish and access your Docker images. Just like GitHub is a place for you to publish and access your git repos.

It’s also worth pointing out that the Docker Hub and other third party repository hosting services are called “registries”. A registry stores a collection of repositories.

You could say a registry has many repositories and a repository has many different versions of the same image which are individually versioned with tags.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Docker push image to a registry

A

docker login
To publish, just type the below command remembering to replace the name of the image tag above with yours. It is important to have the format of yourusername/image_name so that the client knows where to publish.

$ docker push yourusername/catnip

Now that your image is online, anyone who has docker installed can play with your app by typing just a single command.

$ docker run -p 8888:5000 yourusername/catnip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

docker network ls

A

listing docker network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

create network in docker

A

Since the bridge network is shared by every container by default, this method is not secure. How do we isolate our network?

The good news that Docker has a great answer to our questions. It allows us to define our own networks while keeping them isolated using the docker network command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

docker network inspect foodtrucks-net

A

checking whats in foodtrucks-net network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Basic commands to create a network of containers

A
# build the flask container
docker build -t prakhar1989/foodtrucks-web .
# create the network
docker network create foodtrucks-net
# start the ES container
docker run -d --name es --net foodtrucks-net -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.2
# start the flask app container
docker run -d --net foodtrucks-net -p 5000:5000 --name foodtrucks-web prakhar1989/foodtrucks-web
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Some Definitions

A

Docker Machine - Create Docker hosts on your computer, on cloud providers, and inside your own data center
Docker Compose - A tool for defining and running multi-container Docker applications.
Docker Swarm - A native clustering solution for Docker
Kubernetes - Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

kjkj

A

kkj