Docker Flashcards

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

A

COPY –link

25
Q

Term for dockerfile in which multiple FROM statements are used

A

Multi-stage build

26
Q

Argument to COPY used to move files between stages of a multi-stage build

A

FROM {image} As {name}
COPY –from {name}

27
Q

Three types of storage mounts

A

Volumes, bind mounts, tmpfs mounts

28
Q

“-v” Syntax for a volume mount

A

-v {vol_name}:{dest}:{options}

{vol_name} may be excluded for anonymous vol

29
Q

”–mount” syntax for a volume mount

A

–mount type=volume,src={src},dest={dest},ro

30
Q

The main keynames for use with the “–mount” switch

A

type; src; dest; ro; volume-opt

31
Q

CLI command to create a new volume

A

docker volume create {vol_name}

32
Q

CLI command to view volume info

A

docker volume inspect {vol_name}

33
Q

CLI command to delete a volume

A

docker volume rm {vol_name}

34
Q

CLI switch to create a tmpfs volume

A

–tmpfs {dest}

35
Q

CLI switch to create a size limited tempfs volume

A

–mount type=tmpfs,dest={dest},tmpfs-size=xxx

36
Q

Keyword to indicate that a volume should be expected/created at a particular container path

A

VOLUME [“/path”]
VOLUME /path

37
Q

Keyword to set the default user for subsequent commands

A

USER {UID}[:{GID}]

38
Q

Here-document syntax

A

RUN «EOF
apt-get update
apt-get install -y vim
EOF

39
Q

Here-document syntax (non-default shell/interpreter)

A

RUN «EOF
#!/usr/bin/env python
print(“hello python”)
EOF

40
Q

Create an inline file

A

COPY «-EOF /path/to/file
{content of file}
EOF

41
Q

Keyword to inform docker of intent to listen on a port at runtime

A

EXPOSE

42
Q

Default protocol for EXPOSE keyword

A

tcp

43
Q

Syntax to EXPOSE tcp+udp port

A

EXPOSE {port}/tcp
EXPOSE {port}/udp

44
Q

CLI flag to map EXPOSED ports to ephemeral high-ordered ports

A

-P

45
Q

CLI flag to map a port

A

-p 80:80/tcp -p 80:80/udp

46
Q

Magic file listing files to be excluded from context

A

.dockerignore

47
Q

Magic file listing files to be excluded from context

A

.dockerignore

48
Q

Keyword to set an environment variable within build and run stages

A

ENV {key}={val}
ENV {key} {val}

49
Q

CLI syntax to override an environment variable at runtime

A

docker run –env {key}={val}

50
Q

Keyword to set an environment variable within only the run stage

A

ARG {key}[={default_val}]

51
Q

CLI syntax to override a build arg at build time

A

docker build –build-arg {key}={val}

52
Q

Syntax to use a ENV/ARG variable in a RUN command

A

RUN echo $var_name

53
Q

Statement to clear an inherited ENTRYPOINT

A

ENTRYPOINT []

54
Q

How to give a container USB access

A

docker run -it –privileged -v /dev/bus/usb:/dev/bus/usb {container} {cmd}