Docker Flashcards

(54 cards)

1
Q

Keyword to inherit an image

A

FROM {image} [as {name}]

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

Keyword to provide defaults to an executing container

A

CMD

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

“exec” form of CMD

A

CMD [“executable”, “param1”, “param2”]

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

Form of CMD used to provide default parameters to ENTRYPOINT

A

CMD [“param1”, “param2”]

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

shell form of CMD

A

CMD executable param1 param2

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

Keyword for configuring a container which will run as an executable

A

ENTRYPOINT

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

“exec” form of ENTRYPOINT

A

ENTRYPOINT [“exe”, “param1”, “param2”]

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

(CLI)Run a new command in an existing container

A

docker exec -it {container} {cmd}

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

shell form of ENTRYPOINT

A

ENTRYPOINT exe param1 param2

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

(CLI) Override ENTRYPOINT given in Dockerfile

A

docker run –entrypoint {entry cmd}

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

(CLI) Connect to shell in new container

A

docker run -it {img}

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

(CLI) Run a new command in an existing container

A

docker exec -it {container} {cmd}

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

(CLI) Attach to stdio of running container

A

docker attach {container}

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

Keyword to execute command in new layer

A

RUN

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

“exec” form of RUN

A

RUN [“exe”, “param1”, “param2”]

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

shell form of RUN

A

RUN {cmd}

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

Keyword to adjust shell used by RUN

A

SHELL [“exe”, “param”]

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

Default shell used by RUN

A

[“/bin/sh”, “-c”]

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

Keyword to set the working directory

A

WORKDIR {path}

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

Default WORKDIR

A

/

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

Keyword to duplicate files from context into image

A

COPY

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

Additional capabilities of ADD over COPY

A

Retrieve from URL; Unpack local tar/bz2/xz archive

23
Q

How to set user/group ownership w/COPY

A

COPY –chown {uid}:{guid}

24
Q

Prevent invalidation of COPY layer on rebuild

25
Term for dockerfile in which multiple FROM statements are used
Multi-stage build
26
Argument to COPY used to move files between stages of a multi-stage build
FROM {image} As {name} COPY --from {name}
27
Three types of storage mounts
Volumes, bind mounts, tmpfs mounts
28
"-v" Syntax for a volume mount
-v {vol_name}:{dest}:{options} {vol_name} may be excluded for anonymous vol
29
"--mount" syntax for a volume mount
--mount type=volume,src={src},dest={dest},ro
30
The main keynames for use with the "--mount" switch
type; src; dest; ro; volume-opt
31
CLI command to create a new volume
docker volume create {vol_name}
32
CLI command to view volume info
docker volume inspect {vol_name}
33
CLI command to delete a volume
docker volume rm {vol_name}
34
CLI switch to create a tmpfs volume
--tmpfs {dest}
35
CLI switch to create a size limited tempfs volume
--mount type=tmpfs,dest={dest},tmpfs-size=xxx
36
Keyword to indicate that a volume should be expected/created at a particular container path
VOLUME ["/path"] VOLUME /path
37
Keyword to set the default user for subsequent commands
USER {UID}[:{GID}]
38
Here-document syntax
RUN <
39
Here-document syntax (non-default shell/interpreter)
RUN <
40
Create an inline file
COPY <<-EOF /path/to/file {content of file} EOF
41
Keyword to inform docker of intent to listen on a port at runtime
EXPOSE
42
Default protocol for EXPOSE keyword
tcp
43
Syntax to EXPOSE tcp+udp port
EXPOSE {port}/tcp EXPOSE {port}/udp
44
CLI flag to map EXPOSED ports to ephemeral high-ordered ports
-P
45
CLI flag to map a port
-p 80:80/tcp -p 80:80/udp
46
Magic file listing files to be excluded from context
.dockerignore
47
Magic file listing files to be excluded from context
.dockerignore
48
Keyword to set an environment variable within build and run stages
ENV {key}={val} ENV {key} {val}
49
CLI syntax to override an environment variable at runtime
docker run --env {key}={val}
50
Keyword to set an environment variable within only the run stage
ARG {key}[={default_val}]
51
CLI syntax to override a build arg at build time
docker build --build-arg {key}={val}
52
Syntax to use a ENV/ARG variable in a RUN command
RUN echo $var_name
53
Statement to clear an inherited ENTRYPOINT
ENTRYPOINT []
54
How to give a container USB access
docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb {container} {cmd}