CLI Flashcards

1
Q

How to list running containers?

A

With command docker ps

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

How to list all containers (running and stopped)?

A

With command docker ps -a

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

How to build a Docker image from a Dockerfile?

A

With command docker build -t image_name .

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

How to run a Docker container?

A

With command docker run container_name

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

How to run a Docker container in the background?

A

With command docker run -d container_name

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

How to stop a running Docker container?

A

With command docker stop container_id

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

How to start a stopped Docker container?

A

With command docker start container_id

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

How to remove a Docker container?

A

With command docker rm container_id

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

How to force remove a Docker container?

A

With command docker rm -f container_id

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

How to remove a Docker image?

A

With command docker rmi image_id

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

How to list all Docker images?

A

With command docker images

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

How to pull an image from Docker Hub?

A

With command docker pull image_name

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

How to push an image to Docker Hub?

A

With command docker push image_name

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

How to tag a Docker image?

A

With command docker tag source_image target_image

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

How to execute a command in a running container?

A

With command docker exec container_id command

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

How to view logs of a Docker container?

A

With command docker logs container_id

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

How to inspect details of a Docker container?

A

With command docker inspect container_id

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

How to check the resource usage of Docker containers?

A

With command docker stats

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

How to list Docker networks?

A

With command docker network ls

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

How to create a Docker network?

A

With command docker network create network_name

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

How to connect a container to a network?

A

With command docker network connect network_name container_id

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

How to disconnect a container from a network?

A

With command docker network disconnect network_name container_id

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

How to list Docker volumes?

A

With command docker volume ls

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

How to create a Docker volume?

A

With command docker volume create volume_name

25
Q

How to remove a Docker volume?

A

With command docker volume rm volume_name

26
Q

How to rename a Docker container?

A

With command docker rename old_name new_name

27
Q

How to copy files from host to container?

A

With command docker cp host_path container_id:container_path

28
Q

How to copy files from container to host?

A

With command docker cp container_id:container_path host_path

29
Q

How to attach to a running Docker container?

A

With command docker attach container_id

30
Q

How to stop all running Docker containers?

A

With command docker stop $(docker ps -q)

31
Q

How to remove all stopped Docker containers?

A

With command docker rm $(docker ps -a -q)

32
Q

How to remove all Docker images?

A

With command docker rmi $(docker images -q)

33
Q

How to prune unused Docker objects (containers, images, networks, volumes)?

A

With command docker system prune

34
Q

How to prune unused Docker volumes?

A

With command docker volume prune

35
Q

How to prune unused Docker networks?

A

With command docker network prune

36
Q

How to prune unused Docker images?

A

With command docker image prune

37
Q

How to save a Docker image to a tar file?

A

With command docker save -o file_name.tar image_name

38
Q

How to load a Docker image from a tar file?

A

With command docker load -i file_name.tar

39
Q

How to export a container’s filesystem to a tar file?

A

With command docker export -o file_name.tar container_id

40
Q

How to import a container’s filesystem from a tar file?

A

With command docker import file_name.tar

41
Q

How to change the restart policy of a Docker container?

A

With command docker update --restart=policy container_id

42
Q

How to view the history of a Docker image?

A

With command docker history image_name

43
Q

How to log in to a Docker registry?

A

With command docker login registry_url

44
Q

How to log out from a Docker registry?

A

With command docker logout registry_url

45
Q

How to set environment variables in a Docker container?

A

With command docker run -e ENV_VAR_NAME=value container_name

46
Q

How to limit CPU usage of a Docker container?

A

With command docker run --cpus=number container_name

47
Q

How to limit memory usage of a Docker container?

A

With command docker run --memory=amount container_name

48
Q

How to restart a running Docker container?

A

With command docker restart container_id

49
Q

How to run a command in a new container and remove it after execution?

A

With command docker run --rm container_name command

50
Q

How to view Docker daemon logs?

A

With command docker logs container_id

51
Q

How to list all Docker containers sorted by creation time?

A

With command docker ps --sort=created

52
Q

How to list the top processes running inside a Docker container?

A

With command docker top container_id

53
Q

How to inspect a Docker image?

A

With command docker inspect image_name

54
Q

How to display real-time events from the Docker daemon?

A

With command docker events

55
Q

How to show the metadata of a Docker volume?

A

With command docker volume inspect volume_name

56
Q

How to create a Docker image from a container’s changes?

A

With command docker commit container_id new_image_name

57
Q

How to specify a Dockerfile for building an image?

A

With command docker build -f Dockerfile .

58
Q

How to run a container with a specific name?

A

With command docker run --name container_name image_name