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
How to remove a Docker volume?
With command `docker volume rm volume_name`
26
How to rename a Docker container?
With command `docker rename old_name new_name`
27
How to copy files from host to container?
With command `docker cp host_path container_id:container_path`
28
How to copy files from container to host?
With command `docker cp container_id:container_path host_path`
29
How to attach to a running Docker container?
With command `docker attach container_id`
30
How to stop all running Docker containers?
With command `docker stop $(docker ps -q)`
31
How to remove all stopped Docker containers?
With command `docker rm $(docker ps -a -q)`
32
How to remove all Docker images?
With command `docker rmi $(docker images -q)`
33
How to prune unused Docker objects (containers, images, networks, volumes)?
With command `docker system prune`
34
How to prune unused Docker volumes?
With command `docker volume prune`
35
How to prune unused Docker networks?
With command `docker network prune`
36
How to prune unused Docker images?
With command `docker image prune`
37
How to save a Docker image to a tar file?
With command `docker save -o file_name.tar image_name`
38
How to load a Docker image from a tar file?
With command `docker load -i file_name.tar`
39
How to export a container's filesystem to a tar file?
With command `docker export -o file_name.tar container_id`
40
How to import a container's filesystem from a tar file?
With command `docker import file_name.tar`
41
How to change the restart policy of a Docker container?
With command `docker update --restart=policy container_id`
42
How to view the history of a Docker image?
With command `docker history image_name`
43
How to log in to a Docker registry?
With command `docker login registry_url`
44
How to log out from a Docker registry?
With command `docker logout registry_url`
45
How to set environment variables in a Docker container?
With command `docker run -e ENV_VAR_NAME=value container_name`
46
How to limit CPU usage of a Docker container?
With command `docker run --cpus=number container_name`
47
How to limit memory usage of a Docker container?
With command `docker run --memory=amount container_name`
48
How to restart a running Docker container?
With command `docker restart container_id`
49
How to run a command in a new container and remove it after execution?
With command `docker run --rm container_name command`
50
How to view Docker daemon logs?
With command `docker logs container_id`
51
How to list all Docker containers sorted by creation time?
With command `docker ps --sort=created`
52
How to list the top processes running inside a Docker container?
With command `docker top container_id`
53
How to inspect a Docker image?
With command `docker inspect image_name`
54
How to display real-time events from the Docker daemon?
With command `docker events`
55
How to show the metadata of a Docker volume?
With command `docker volume inspect volume_name`
56
How to create a Docker image from a container's changes?
With command `docker commit container_id new_image_name`
57
How to specify a Dockerfile for building an image?
With command `docker build -f Dockerfile .`
58
How to run a container with a specific name?
With command `docker run --name container_name image_name`