Create Images Flashcards

1
Q

what are FROM scratch and FROM ParentImage?

A

FROM scratch is used to create a Base Image and the other is to create and image From ParentImage

https://docs.docker.com/build/building/base-images/

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

What is a Base Image?

A

A base image has no parent image specified in its Dockerfile. It is created using a Dockerfile with the FROM scratch directive.

https://docs.docker.com/glossary/#base-image

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

What is a Parent Image?

A

An image’s parent image is the image designated in the FROM directive in the image’s Dockerfile

https://docs.docker.com/glossary/#parent-image

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

What is RUN <command> instruction?

A

Executes any commands in a new layer on top of the current image and commits the result.

https://docs.docker.com/build/building/packaging/

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

What is From <image> instruction?

A

Defines a base for your image.

https://docs.docker.com/build/building/packaging/

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

What is WORKDIR <directory> instruction?

A

Sets the working directory for any RUN, CMD, ENTRYPOINT, COPY, and ADD instructions that follow it in the Dockerfile.

https://docs.docker.com/build/building/packaging/

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

What is COPY <src> <dest> instruction?

A

Copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.

https://docs.docker.com/build/building/packaging/

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

What is CMD <command>instruction?

A

Lets you define the default program that is run once you start the container based on this image

https://docs.docker.com/build/building/packaging/

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

what is ARG <name>[=<default value>] instruction?

A

The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command using the --build-arg <varname>=<value> flag

https://docs.docker.com/engine/reference/builder/#arg

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

Which istruction is first From or ARG?

A

FROM

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

Is Possible to set a defaul value on a ARG instruction.

A

YES
ARG var_name=<def value>

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

Wha is LABEL <key>=<value> <key>=<value> <key>=<value> ... instruction?

A

The LABEL instruction adds metadata to an image

https://docs.docker.com/engine/reference/builder/#label:~:text=LABEL-,%F

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

What is ADD [--chown=<user>:<group>] [--checksum=<checksum>] <src>... <dest> instruction?

A

The ADD instruction copies new files, directories or remote file URLs from <src> and adds them to the filesystem of the image at the path <dest>.

https://docs.docker.com/engine/reference/builder/#add:~:text=ENV-,ADD,-V

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

what is COPY in Dockerfile command. [--chown=<user>:<group>] <src>... <dest> instruction?

A

The COPY instruction copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.

https://docs.docker.com/engine/reference/builder/#copy:~:text=COPY-,%F0%

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

What is ENTRYPOINT ["executable", "param1", "param2"] instruction?

A

An ENTRYPOINT allows you to configure a container that will run as an executable.

+ ENTRYPOINT ["executable", "param1", "param2"]
+ ENTRYPOINT command param1 param2

https://docs.docker.com/engine/reference/builder/#entrypoint

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

What is EXPOSE <port> [<port>/<protocol>...] instruction?

A

The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime.

The default protocol is TCP if the protocol is not specified.

It create a Metadata but not a layer into the image

https://docs.docker.com/engine/reference/builder/#expose:~:text=MAINTAIN

17
Q

What is the command to build an image from a Dockerfile

A

+ docker image build [OPTIONS] PATH|URL
+ docker build [OPTIONS] PATH|URL

On PATH , you ca use . to set the current directory where Dockerfile is.

18
Q

How can we set a name and tag at building time of an Image?

A

using the flag -t

+ docker image build -t <name>:<tag>
+ docker build -t <name>:<tag>

docker build –help

19
Q

What is the command to login to Dockers?

A

docker login

After that, user and password shall be required.

20
Q

What is the command to tag an Image?

A

docker image tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

Where:
+ SOURCE_IMAGE[:TAG] is the name set on build commando with the flag -t.
+ TARGET_IMAGE[:TAG] is the full name that MUST include the Docker ID i.e:

docker image tag web:latest nigelpoulton/web:latest

You Must be logget.

21
Q

What is the command to publish an image?

A

docker image push TARGET_IMAGE[:TAG]

+ TARGET_IMAGE[:TAG] is the full name that MUST include the Docker ID i.e:

docker image push nigelpoulton/web:latest

You Must be logget.

22
Q

What do you need to create an Linux Base Image (scratch)?

A

It’s necessary to know the basic package to add to have the basic functionality.

For example, for linux:
```cmd
FROM scratch
ADD ubuntu-kinetic-oci-amd64-root.tar.gz /
CMD [“bash”]
~~~

Manjaro linux:
```cmd
FROM scratch
ADD manjaro.tar /
ENV LANG=en_US.UTF-8
CMD [“/usr/bin/bash”]
~~~

23
Q

What are VOLUMES?

A

volumes defines mount host paths or named volumes that MUST be accessible by service containers.

+ Volumes are the preferred mechanism for persisting data generated by and used by Docker containers.
+ They are complete managed by DOcker

https://docs.docker.com/storage/volumes/
https://docs.docker.com/compose

24
Q

What is the basic structure to declare a VOLUME and what is its function?

A

<Local File Systema Path>:<Containte Mount Path>

Mapping a local directories into Container

https://docs.docker.com/storage/volumes/#start-a-container-with-a-volume

https://docs.docker.com/compose/compose-file/#volumes

25
Q

What is the command to celar all unusued data un docker?

A

docker system prune

YOU MUST USED THIS COMMAND CAREFULLY!

26
Q

How to list all the volumes created?

A

docker volume ls

27
Q

How to remove all volumes in docker?

A

docker volume prune