General Flashcards

1
Q

What is Docker?

A

Docker is an open platform for developing, shipping, and running applications in containers.

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

What are Docker containers?

A

Docker containers are lightweight, standalone, executable packages that include everything needed to run a piece of software, including the code, runtime, libraries, and settings.

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

How does Docker differ from virtual machines?

A

Docker containers share the host system’s kernel and resources, making them more lightweight and efficient compared to virtual machines, which require a full OS instance for each VM.

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

What command is used to list all Docker containers?

A

The command is ‘docker ps’ for running containers and ‘docker ps -a’ for all containers. PS stands for “Process Status”

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

What file is used to define a multi-container Docker application?

A

A Docker Compose file, usually named ‘docker-compose.yml’, is used to define multi-container Docker applications.

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

How do you build a Docker image from a Dockerfile?

A

Use the command ‘docker build -t image_name .’, where ‘image_name’ is your desired image name and ‘.’ specifies the current directory containing the Dockerfile.

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

What is the purpose of a Dockerfile?

A

A Dockerfile is a script containing a series of instructions on how to build a Docker image.

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

What command is used to start a Docker container?

A

The command is ‘docker run’.

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

How do you remove a Docker container?

A

Use the command ‘docker rm container_id’, where ‘container_id’ is the ID of the container you want to remove.

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

What command is used to stop a running Docker container?

A

The command is ‘docker stop container_id’, where ‘container_id’ is the ID of the running container.

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

How can you view the logs of a Docker container?

A

Use the command ‘docker logs container_id’.

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

What is Docker Hub?

A

Docker Hub is a cloud-based repository where Docker users can create, test, store, and distribute container images.

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

How do you pull an image from Docker Hub?

A

Use the command ‘docker pull image_name’.

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

What is the purpose of the ‘docker-compose up’ command?

A

The ‘docker-compose up’ command starts and runs the entire application as defined in the ‘docker-compose.yml’ file.

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

How do you share data between Docker containers?

A

You can share data between Docker containers using Docker volumes.

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

What is a Docker volume?

A

A Docker volume is a storage mechanism that allows data to persist beyond the lifecycle of a container.

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

How do you create a Docker network?

A

Use the command ‘docker network create network_name’.

18
Q

What is the purpose of Docker Swarm?

A

Docker Swarm is a native clustering and orchestration tool for Docker, enabling the management of a cluster of Docker nodes as a single virtual system.

19
Q

How do you update a service in Docker Swarm?

A

Use the command ‘docker service update service_name’.

20
Q

What is the purpose of the ‘EXPOSE’ instruction in a Dockerfile?

A

The ‘EXPOSE’ instruction informs Docker that the container listens on the specified network ports at runtime.

21
Q

What is the ‘ENTRYPOINT’ instruction in a Dockerfile?

A

The ‘ENTRYPOINT’ instruction specifies the command that will run when a container is started from the image.

22
Q

What is the difference between ‘CMD’ and ‘ENTRYPOINT’ in a Dockerfile?

A

‘CMD’ provides default arguments for the ‘ENTRYPOINT’ instruction, whereas ‘ENTRYPOINT’ defines the main command to run in the container.

23
Q

How do you restart a stopped Docker container?

A

Use the command ‘docker start container_id’.

24
Q

What command is used to remove a Docker image?

A

The command is ‘docker rmi image_id’, where ‘image_id’ is the ID of the image you want to remove.

25
Q

How do you list all Docker images on your system?

A

Use the command ‘docker images’.

26
Q

What is the ‘docker exec’ command used for?

A

The ‘docker exec’ command is used to run a command in a running container.

27
Q

How can you check the resource usage of Docker containers?

A

Use the command ‘docker stats’.

28
Q

What is the purpose of the ‘VOLUME’ instruction in a Dockerfile?

A

The ‘VOLUME’ instruction creates a mount point with the specified path and marks it as holding externally mounted volumes from native host or other containers.

29
Q

How do you preview the details of a Docker container?

A

Use the command ‘docker inspect container_id’.

30
Q

What is a Docker registry?

A

A Docker registry is a storage and distribution system for Docker images.

31
Q

How can you limit the memory usage of a Docker container?

A

Use the ‘–memory’ flag with ‘docker run’, e.g., ‘docker run –memory=512m container_name’.

32
Q

What is the ‘FROM’ instruction in a Dockerfile?

A

The ‘FROM’ instruction specifies the base image to use for the Docker image being built.

33
Q

What is the use of ‘WORKDIR’ in a Dockerfile?

A

The ‘WORKDIR’ instruction sets the working directory for any subsequent instructions in the Dockerfile.

34
Q

How do you attach to a running Docker container?

A

Use the command ‘docker attach container_id’.

35
Q

What is the purpose of the ‘.dockerignore’ file?

A

The ‘.dockerignore’ file is used to specify files and directories to exclude from the Docker build context, similar to a ‘.gitignore’ file.

36
Q

How do you copy files from the host system to a Docker container?

A

Use the ‘docker cp’ command, e.g., ‘docker cp host_path container_id:container_path’.

37
Q

What is the ‘LABEL’ instruction in a Dockerfile?

A

The ‘LABEL’ instruction adds metadata to an image, such as a description, version, or maintainer.

38
Q

How do you rename a Docker container?

A

Use the command ‘docker rename old_name new_name’.

39
Q

What is Docker’s default network driver?

A

Docker’s default network driver is ‘bridge’.

40
Q

How do you run a Docker container in the background?

A

Use the ‘-d’ flag with ‘docker run’, e.g., ‘docker run -d container_name’.