Create Images Flashcards
what are FROM scratch
and FROM ParentImage
?
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/
What is a Base Image?
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
What is a Parent Image?
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
What is RUN <command>
instruction?
Executes any commands in a new layer on top of the current image and commits the result.
https://docs.docker.com/build/building/packaging/
What is From <image>
instruction?
Defines a base for your image.
https://docs.docker.com/build/building/packaging/
What is WORKDIR <directory>
instruction?
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/
What is COPY <src> <dest>
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/build/building/packaging/
What is CMD <command>
instruction?
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/
what is ARG <name>[=<default value>]
instruction?
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
Which istruction is first From
or ARG
?
FROM
Is Possible to set a defaul value on a ARG
instruction.
YESARG var_name=<def value>
Wha is LABEL <key>=<value> <key>=<value> <key>=<value> ...
instruction?
The LABEL
instruction adds metadata to an image
https://docs.docker.com/engine/reference/builder/#label:~:text=LABEL-,%F
What is ADD [--chown=<user>:<group>] [--checksum=<checksum>] <src>... <dest>
instruction?
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
what is COPY in Dockerfile command.
[--chown=<user>:<group>] <src>... <dest>
instruction?
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%
What is ENTRYPOINT ["executable", "param1", "param2"]
instruction?
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
What is EXPOSE <port> [<port>/<protocol>...]
instruction?
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
What is the command to build an image from a Dockerfile
+ docker image build [OPTIONS] PATH|URL
+ docker build [OPTIONS] PATH|URL
On PATH
, you ca use .
to set the current directory where Dockerfile
is.
How can we set a name and tag at building time of an Image?
using the flag -t
+ docker image build -t <name>:<tag>
+ docker build -t <name>:<tag>
docker build –help
What is the command to login to Dockers?
docker login
After that, user and password shall be required.
What is the command to tag an Image?
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.
What is the command to publish an image?
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.
What do you need to create an Linux Base Image (scratch)?
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”]
~~~
What are VOLUMES?
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
What is the basic structure to declare a VOLUME and what is its function?
<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
What is the command to celar all unusued data un docker
?
docker system prune
YOU MUST USED THIS COMMAND CAREFULLY!
How to list all the volumes created?
docker volume ls
How to remove all volumes in docker?
docker volume prune