Docker image Flashcards

1
Q

What is the first step in creating your own image for a container?

A

For eg. considering running a web application,

  1. Write down what are the steps you would do if you had to run this web application manually without using container -
  2. OS - Ubuntu
  3. Update apt repo
  4. Install dependencies using apt
  5. Install Python dependencies using pip
  6. copy source code to /opt folder
  7. Run the webserver using “flask” command
  8. Then create a docker file and write down the procedure for creating the application in it
  9. Use the docker build command to build the image

There is an image in this studyset with a picture explaining. see that`

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

How to create your own image to be run in the docker container?

A
  1. Write down what are the steps you would do if you had to run this web application manually without using container
  2. Then create a docker file and write down the procedure for creating the application in it
  3. Use the docker build command to build the image
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Can you write a docker build command to build an image using docker file?

A

docker build DockerFile -t mumshad/my-custom-app

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

what does an example docker file look like?

A

Instruction - Argument format

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

What are the rules when writing a docker file?

A
  1. Start from the base OS or another image
  2. Install all dependencies
  3. Copy the source code
  4. Specify Entry Point
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is meant by the entry point in a docker file?

A

Whatever we specify in the entry point is the command to be run when the docker creates a container using the image created using that docker file.

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

How does docker build an image using the docker file?

A

When Docker builds the images, it builds
these in a layered architecture. Each line of
instruction creates a new layer in the docker
image with just the changes from the
previous layer. For example, the first layer is a base
Ubuntu OS, followed by the second
instruction that creates a second
layer, which installs all the apt packages, and
then the third instruction creates a third layer
with the Python packages, followed by the
fourth layer that copies the source code over,
and the final layer that updates the entry point of the image. Since each layer only stores the changes
from the previous layer, it is reflected in the
size as well.
If you look at the base Ubuntu image, it is
around 120 MB in size. The apt package that
l install is around 300 MB, and the remaining
layers are small.
You could see this information if you run the
docker history command, followed by the
image name. When you run the docker build
command,

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

I want to create a docker container for running Ubuntu and as soon as the container is up I want to connect to it in an interactive mode and enter bash command?

A

docker run -it ubuntu bash

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