Docker Flashcards

1
Q

What is the command to output the version of the installed Client and Server?

A

docker version

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

What is the command to list the images that have been downloaded to the machine?

A

docker image ls

docker images

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

What is the command to output detailed information about the docker installation?

A

docker info

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

What is the command to list the running containers?

A

docker ps

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

What is the command to list all containers on the system?

A

docker ps -a

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

What is the command to show the last running container?

A

docker ps -al

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

What is the command to run an image?

A

docker run [IMAGE]

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

What switch should be used with the docker run command to delete the container immediately after it exits?

A

-rm

Full command: docker run -rm [IMAGE]

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

What switch should be used with the docker run command to run the container in interactive mode?

A

-ti

Full command: docker run -ti [IMAGE] [PROCESS]
Example: docker run -ti ubuntu bash

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

What switch should be used with the docker run command to run the container detached in the background?

A

-d

Full command: docker run -d [IMAGE] [PROCESS]

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

What switch should be used with the docker run command to give the container a custom name?

A

–name [NAME]

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

What switch should be used with the docker run command to forward a port out of the container?

A

-p [CONTAINER PORT]:[LOCAL PORT]

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

What is the command to stop a running container?

A

docker stop [CONTAINER NAME]

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

What is the command to remove a stopped container?

A

docker rm [CONTAINER NAME]

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

What is the command to view the logs of a running container?

A

docker logs [CONTAINER NAME]

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

What is the command to remove an image?

A

docker rmi -f [IMAGE]

17
Q

What is the command to build a docker image from a Dockerfile in the same directory?

A

docker build -t [IMAGE NAME] .

18
Q

What is the command to access the terminal of a running container?

A

docker exec -ti [CONTAINER NAME] bash

19
Q

What is the command to clean up dangling images?

A

docker image prune
or
docker rmi -f $(docker images -qf “dangling=true”)

20
Q

What is the command to clean up old docker images, containers, volumes, etc.?

A

docker system prune