Share with friends
More on the topic
Docker Books
Docker Interview Questions - Beginner Level
Docker Interview Questions - Medium Level Part 1
Docker Interview Questions - Medium Level Part 2
Docker Interview Questions - Advanced Level Part 1
Docker Interview Questions - Advanced Level Part 2
Docker Interview Questions - Advanced Level Part 3
Docker Interview Questions - Advanced Level Part 4
Docker Medium-Level Interview Questions and Answers
1. What is a Docker volume and how do you create one?
**Answer:**A Docker volume is like a storage space for data that your Docker containers create and use. Unlike bind mounts, Docker itself manages Docker volumes, making them easier to move around. To make a Docker volume, use this command:
docker volume create my_volume
You can then use this volume in a container with:
docker run -v my_volume:/data my_image
2. Explain the difference between COPY
and ADD
in a Dockerfile.
Answer: Both COPY
and ADD
are used to copy files from the host machine into the Docker image. However, ADD
provides additional functionality:
COPY
simply copies files and directories.ADD
can also copy files from a URL and handle automatic extraction of compressed files (e.g.,.tar
).
# COPY example
COPY my_file.txt /app/
# ADD example
ADD my_archive.tar /app/
ADD https://example.com/file.txt /app/file.txt
3. What are Docker namespaces and how do they work?
Answer: Docker namespaces provide isolation for various resources, ensuring containers are separated from each other and from the host system. Key namespaces include:
- PID namespace: Isolates process IDs.
- NET namespace: Provides isolated network interfaces.
- IPC namespace: Isolates inter-process communication resources.
- MNT namespace: Isolates filesystem mounts.
- UTS namespace: Isolates hostname and domain name.
Each container runs in its own set of namespaces, which provides the required isolation.
4. How do you use Docker Compose to define and run multiple containers?
Answer: Docker Compose uses a YAML file (docker-compose.yml
) to define services, networks, and volumes for multi-container Docker applications. Example:
version: '3'
services:
web:
image: nginx
ports:
- "8080:80"
db:
image: postgres
environment:
POSTGRES_PASSWORD: example
To start the services, run:
docker-compose up
5. What is the difference between a Docker registry and a repository?
Answer: A Docker registry is a storage and distribution system for Docker images. It can contain multiple repositories. A repository is a collection of related Docker images, often grouped by the same name but different tags (versions).
- Registry example: Docker Hub (a public registry)
- Repository example:
nginx
, containing tags likelatest
,1.19
,alpine
6. How do you remove dangling images in Docker?
Answer: Dangling images are unused images that are not tagged and not referenced by any container. To remove them, use:
docker image prune
7. What is the purpose of the docker-compose.override.yml
file?
Answer: The docker-compose.override.yml
file is used to override settings in the main docker-compose.yml
file. It allows you to define configurations that should be applied on top of the existing setup, such as development-specific settings.
8. How can you persist data in Docker containers?
Answer: You can persist data in Docker containers using volumes or bind mounts:
-
Volumes: Managed by Docker, suitable for data that needs to persist across container restarts.
docker run -v my_volume:/data my_image
-
Bind mounts: Connect a folder on your computer to a folder inside the container.
docker run -v /host/data:/container/data my_image
9. Explain the use of the docker network
command.
Answer: The docker network
command is used to manage Docker networks. You can create, inspect, and remove networks. Example commands:
- Create a network:
docker network create my_network
- List networks:
docker network ls
- Inspect a network:
docker network inspect my_network
10. What is the role of the ENTRYPOINT
instruction in a Dockerfile?
Answer: The ENTRYPOINT
instruction specifies the command that will always run when a container starts. It allows you to configure a container to run as an executable. Unlike CMD
, ENTRYPOINT
does not get overridden by command-line arguments passed to docker run
.
ENTRYPOINT ["executable", "param1", "param2"]
11. How can you build a Docker image using a specific Dockerfile?
Answer: Use the -f
flag with the docker build
command to specify a particular Dockerfile.
docker build -t my_image -f /path/to/Dockerfile .
12. How do you handle secrets in Docker Swarm?
Answer: Docker Swarm has built-in support for secrets management. You can create a secret and use it in services:
- Create a secret:
echo "my_secret" | docker secret create my_secret -
- Use the secret in a service:
version: '3.1' services: my_service: image: my_image secrets: - my_secret secrets: my_secret: external: true
13. What is the difference between docker pause
and docker stop
?
Answer:
docker pause
suspends all processes in a container by freezing their execution.docker stop
gracefully stops a running container by sending a SIGTERM signal, followed by a SIGKILL if the container does not stop in a timely manner.
14. How can you update a running Docker service in Swarm mode?
Answer: Use the docker service update
command to update a service. For example, to update the image version:
docker service update --image my_image:latest my_service
15. Explain the HEALTHCHECK
instruction in a Dockerfile.
Answer: The HEALTHCHECK
instruction defines a command to test whether the container is healthy. Example:
HEALTHCHECK CMD curl --fail http://localhost:80 || exit 1
If the health check fails, Docker marks the container as unhealthy.
16. How do you configure a Docker container to automatically restart?
Answer: Use the --restart
flag with docker run
to configure restart policies. Examples:
- Always restart:
docker run --restart always my_image
- Restart on failure:
docker run --restart on-failure my_image
17. What is the difference between a bind mount and a volume in Docker?
Answer:
- Bind mounts: Mount a host directory into a container. Changes on the host affect the container and vice versa.
docker run -v /host/path:/container/path my_image
- Volumes: Managed by Docker, more portable and safer. Suitable for persistent data.
docker run -v my_volume:/container/path my_image
18. What are the main components of Docker Swarm architecture?
Answer: Docker Swarm architecture includes:
- Managers: Manage the swarm and maintain cluster state.
- Workers: Execute tasks assigned by managers.
- Services: Define the desired state of an application.
- Tasks: Units of work assigned to workers.
19. How do you rollback a Docker service to a previous version in Swarm mode?
Answer: The docker service rollback
command is used to turn back a service to its previous version.
docker service rollback my_service
20. What is a multi-stage build in Docker and why is it useful?
Answer: A multi-stage build allows you to use multiple FROM
statements in a Dockerfile to create more efficient images. This approach lets you copy only the necessary artifacts from one stage to another, reducing image size.
# First stage
FROM golang:alpine AS builder
WORKDIR /app
RUN go build -o myapp
# Second stage
FROM alpine
COPY /app/myapp /app/
ENTRYPOINT ["/app/myapp"]
21. How can you inspect the environment variables of a running container?
Answer: Use the docker inspect
command and filter the output to show environment variables.
docker inspect -f '{{json .Config.Env}}' my_container
22. Explain the concept of service discovery in Docker Swarm.
Answer: Service discovery in Docker Swarm allows services to find each other by name, making it easier to connect components of a distributed application. Each service is assigned a DNS name that can be used within the swarm. Docker Swarm automatically updates the DNS records, providing load balancing and failover across the tasks of the service. For example, if you have a service called web
, other services can connect to it using http://web
.
23. How do you limit the memory usage of a Docker container?
Answer: Use the --memory
flag to set a memory limit for a container. This ensures that the container cannot exceed the specified memory, helping prevent out-of-memory errors. For example, to limit a container to 512 MB of memory:
docker run --memory 512m my_image
24. What is Docker Compose and how is it useful?
Answer: Docker Compose is a nifty tool that lets you organize and control Docker applications with multiple containers. Think of it as a simple YAML file that takes care of the nitty-gritty of orchestrating and managing the lifecycle of these containers. It's a lifesaver when you're working with complex applications that involve various services, networks, and volumes. Plus, it's a great way to automate deployment processes, making your life a whole lot easier. With a docker-compose.yml
file, you can start all services with a single command:
docker-compose up
25. How can you view the logs of a specific service in Docker Swarm?
Answer: Use the docker service logs
command to view the logs of a specific service. This command aggregates logs from all tasks of the service. For example, to view logs for a service named my_service
:
docker service logs my_service
26. What is Docker Hub and how do you use it?
Answer: Docker Hub is a cloud-based registry service that allows you to store, share, and manage Docker images. It provides public and private repositories, automated builds, and team collaboration features. To use Docker Hub, you can push and pull images:
# Login to Docker Hub
docker login
# Push an image to Docker Hub
docker push username/my_image
# Pull an image from Docker Hub
docker pull username/my_image
27. How do you scale a service in Docker Swarm?
Answer: Use the docker service scale
command to adjust the number of replicas for a service. This helps manage load and ensure high availability. For example, to scale a service named my_service
to 3 replicas:
docker service scale my_service=3
28. What is the docker system df
command used for?
Answer: The docker system df
command provides a summary of Docker's disk usage, including information about images, containers, volumes, and build cache. It helps you understand how much disk space Docker is consuming and identify opportunities to free up space. For example:
docker system df
29. How can you inspect the network configuration of a Docker container?
Answer: To find out more about a container, like its network setup, you can use the docker inspect
command. For instance, if you want to see the network details of a container called my_container
, you can do this:
docker inspect my_container
30. What is a Docker context and how do you use it?
Answer: A Docker context is a configuration that allows you to switch between different Docker environments, such as local Docker engine, remote Docker hosts, or Kubernetes clusters. It simplifies managing multiple environments. You can create and use contexts with the following commands:
# Create a new context
docker context create my_context --docker "host=ssh://user@remote"
# List available contexts
docker context ls
# Use a specific context
docker context use my_context
31. Explain the docker tag
command.
Answer: The docker tag
command creates a new tag for an existing Docker image. This is useful for versioning and organizing images. For example, to tag an image my_image
with a new version v1.0
:
docker tag my_image username/my_image:v1.0
32. How do you manage environment variables in a Docker Compose file?
Answer: Environment variables in Docker Compose can be managed in several ways:
- Directly in the Compose file:
services: my_service: image: my_image environment: - MY_VAR=value
- Using an
.env
file:And in theversion: '3' services: my_service: image: my_image env_file: - .env
.env
file:MY_VAR=value
33. How do you create a user-defined network in Docker?
Answer: Use the docker network create
command to create a user-defined network. This allows containers to communicate with each other on the same network. For example, to create a network named my_network
:
docker network create my_network
You can then connect containers to this network:
docker run --network my_network my_image
34. What is the purpose of the docker save
and docker load
commands?
Answer:
docker save
: Exports a Docker image to a tar archive, allowing you to save the image locally or transfer it to another system.docker save -o my_image.tar my_image
docker load
: Imports an image from a tar archive.docker load -i my_image.tar
35. How do you configure Docker to use a proxy server?
Answer: To configure Docker to use a proxy server, you need to set environment variables in the Docker service configuration file (e.g., /etc/systemd/system/docker.service.d/http-proxy.conf
):
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80"
Environment="HTTPS_PROXY=https://proxy.example.com:443"
Then reload the Docker service:
sudo systemctl daemon-reload
sudo systemctl restart docker
36. Explain the concept of overlay networks in Docker Swarm.
Answer: Overlay networks in Docker Swarm provide a way for containers running on different hosts to communicate securely. Overlay networks create a virtual network that spans all nodes in the swarm, enabling services to connect seamlessly. They are useful for deploying distributed applications and services that require cross-host communication.
37. How can you restart a Docker container automatically on failure?
Answer: Use the --restart
flag with docker run
to set a restart policy. For example, to restart a container on failure:
docker run --restart on-failure my_image
38. What is the purpose of the docker stats
command?
Answer: The docker stats
command provides real-time metrics of container resource usage, such as CPU, memory, and network I/O. This helps monitor the performance of running containers. Example:
docker stats my_container
39. How do you specify the build context when building a Docker image?
Answer: The build context is the directory you specify when running the docker build
command. It defines the files and directories that can be accessed by the Dockerfile during the build process. For example, to set the current directory as the build context:
docker build -t my_image .
40. How can you limit the CPU usage of a Docker container?
Answer: Use the --cpus
flag to limit the CPU usage of a container. For example, to limit a container to use at most 1.5 CPUs:
docker run --cpus 1.5 my_image
41. What is the difference between docker run
and docker create
?
Answer:
docker run
: Creates and starts a container in one command.docker create
: Only creates a container but does not start it. You can start it later withdocker start
.
42. How do you use a Dockerfile to create an image from a specific base image?
Answer: Use the FROM
instruction in the Dockerfile to specify the base image. For example, to use alpine
as the base image:
FROM alpine
43. How do you attach to a running Docker container?
Answer: Use the docker attach
command to connect your terminal to a running container, allowing you to interact with it. For example:
docker attach my_container
44. What is the purpose of the docker wait
command?
Answer: The docker wait
command blocks until a container stops and then prints the container's exit code. This can be useful in scripts to wait for a container to finish before proceeding.
45. How can you clean up unused Docker resources?
Answer: Use the docker system prune
command to remove unused data, such as stopped containers, unused networks, and dangling images. For example:
docker system prune -a
46. What is Docker Swarm mode and how do you initialize it?
Answer: Docker Swarm mode is Docker's native clustering and orchestration solution. It allows you to manage a cluster of Docker engines as a single swarm. To initialize a swarm, use:
docker swarm init
47. How do you join a node to a Docker Swarm?
Answer: Use the join token provided by the manager node to add a new node to the swarm. For example:
docker swarm join --token <TOKEN> <MANAGER_IP>:<PORT>
48. Explain the concept of Docker secrets and how to use them.
Answer: Docker secrets are a secure way to manage sensitive data, such as passwords and API keys, in a Docker Swarm. Secrets are encrypted and only accessible to services that need them. To create and use a secret:
- Create a secret:
echo "my_secret_value" | docker secret create my_secret -
- Use the secret in a service:
version: '3.1' services: my_service: image: my_image secrets: - my_secret secrets: my_secret: external: true
49. How do you configure logging drivers in Docker?
Answer: Docker supports multiple logging drivers, such as json-file
, syslog
, and journald
. You can set the logging driver for a container using the --log-driver
flag:
docker run --log-driver syslog my_image
You can also configure the default logging driver in the Docker daemon configuration file (/etc/docker/daemon.json
).
50. What is a Docker stack and how do you deploy it?
Answer: A Docker stack is a collection of services that make up an application in a Docker Swarm. You define a stack using a docker-compose.yml
file and deploy it with the docker stack deploy
command. For example:
docker stack deploy -c docker-compose.yml my_stack
51. How do you use the docker cp
command?
Answer: The docker cp
command copies files or directories between a container and the host. For example, to copy a file from the container to the host:
docker cp my_container:/path/to/file /host/path
52. What is the purpose of the docker exec
command?
Answer: The docker exec
command runs a new command in an existing container. This is useful for debugging or running administrative tasks. For example:
docker exec -it my_container /bin/bash
53. How do you specify the hostname of a Docker container?
Answer: Use the --hostname
flag with docker run
to set the container's hostname. For example:
docker run --hostname my_host my_image
54. Explain the use of the EXPOSE
instruction in a Dockerfile.
Answer: The EXPOSE
instruction informs Docker that the container will listen on the specified network ports at runtime. This does not publish the ports; it only serves as documentation and a hint for users. For example:
EXPOSE 80
55. How do you use Docker labels?
Answer: Docker labels are key-value pairs used to organize and manage Docker objects (e.g., images, containers, volumes). You can add labels with the --label
flag:
docker run --label "env=production" my_image
You can also specify labels in a Dockerfile:
LABEL "maintainer"="[email protected]"
56. What is the purpose of the docker history
command?
Answer: The docker history
command shows the history of an image, including the creation time, size, and commands used to build each layer. For example:
docker history my_image
57. How can you manage Docker plugins?
Answer: Docker plugins extend Docker's functionality. You can install, enable, disable, and remove plugins using the docker plugin
command. For example:
- Install a plugin:
docker plugin install my_plugin
- Enable a plugin:
docker plugin enable my_plugin
58. Explain the concept of Docker multi-arch images.
Answer: Docker multi-arch images allow you to build and distribute images that can run on multiple CPU architectures (e.g., x86, ARM). These images contain multiple variants for different architectures, enabling cross-platform compatibility. You can use Docker Buildx to create multi-arch images.
59. How do you remove unused Docker volumes?
Answer: Use the docker volume prune
command to remove all unused volumes. For example:
docker volume prune
60. What is the difference between a service and a container in Docker Swarm?
Answer:
- Service: A higher-level abstraction in Docker Swarm that defines how containers (tasks) are deployed and managed across the swarm. Services ensure the desired state, such as the number of replicas and update policies.
- Container: The actual instance of a running image. In Swarm mode, containers are tasks managed by services.
61. How do you inspect the configuration of a Docker service?
Answer: Use the docker service inspect
command to view detailed information about a service's configuration. For example:
docker service inspect my_service
62. What is the purpose of the docker volume
command?
Answer: The docker volume
command is used to create, inspect, list, and remove Docker volumes. Volumes are useful for persisting data and sharing data between containers. For example, to create a volume:
docker volume create my_volume
63. How do you build a Docker image from a Dockerfile in a specific directory?
Answer: Use the -f
flag with the docker build
command to specify the Dockerfile and the build context. For example, to build an image from a Dockerfile in a directory named dockerfiles
:
docker build -f dockerfiles/Dockerfile -t my_image .
64. What is the purpose of the docker commit
command?
Answer: With the docker commit
command, you can easily create a brand new image based on the changes made in a container. It's like taking a snapshot of the container's current state and turning it into an image.. For example:
docker commit my_container my_new_image
65. How can you optimize Docker image size?
Answer: To optimize Docker image size, you can:
- Use multi-stage builds to reduce the final image size.
- Minimize the number of layers by combining commands in the Dockerfile.
- Use smaller base images, such as
alpine
. - Clean up unnecessary files and dependencies in the Dockerfile.
66. What is the purpose of the docker service rm
command?
Answer: The docker service rm
command removes a service from the swarm, stopping all associated tasks. For example:
docker service rm my_service
67. How do you configure resource limits for Docker services in Swarm mode?
Answer: Use the deploy.resources
section in the docker-compose.yml
file to set resource limits for services. For example:
version: '3.1'
services:
my_service:
image: my_image
deploy:
resources:
limits:
cpus: '0.5'
memory: '512M'
68. How do you handle container logs in Docker Compose?
Answer: Docker Compose logs can be viewed with the docker-compose logs
command, which aggregates logs from all services defined in the Compose file. For example:
docker-compose logs my_service
69. What is a Docker stack file and how do you create one?
Answer: A Docker stack file is a YAML file used to define a stack of services for deployment in a Docker Swarm. It is similar to a Docker Compose file but tailored for Swarm. Example:
version: '3.1'
services:
web:
image: nginx
ports:
- "80:80"
db:
image: postgres
environment:
POSTGRES_PASSWORD: example
70. How do you manage Docker networks?
Answer: Use the docker network
command to create, inspect, list, and remove Docker networks. For example, to create a new network:
docker network create my_network
71. Explain the concept of Docker service update strategies.
Answer: Docker service update strategies define how a service is updated when a new version of the image is deployed. There are two main strategies:
- Rolling update: Updates tasks one or a few at a time, minimizing downtime.
- Recreate: Stops and restarts all tasks at once.
72. How do you run a command in an existing Docker container?
Answer: Use the docker exec
command to run a command in an existing container. For example, to run a shell in a container:
docker exec -it my_container /bin/bash
73. What is the purpose of the docker-compose down
command?
Answer: The docker-compose down
command stops and removes containers, networks, and volumes created by docker-compose up
. This is useful for cleaning up resources:
docker-compose down
74. How can you share data between Docker containers?
Answer: Use Docker volumes or bind mounts to share data between containers. For example, to use a volume:
docker run -v my_volume:/data my_image
75. What is Docker Buildx and how is it used?
Answer: Docker Buildx is an extension of the Docker CLI that provides advanced build capabilities, such as multi-platform builds and cache import/export. It allows you to build images for multiple architectures. Example:
docker buildx build --platform linux/amd64,linux/arm64 -t my_image .
76. Explain the concept of Docker health checks.
Answer: Docker health checks allow you to define a command in the Dockerfile to test if the container is healthy. Docker periodically runs the health check command and updates the container's health status. Example:
HEALTHCHECK CMD curl --fail http://localhost/health || exit 1
77. How do you use Docker secrets in Docker Compose?
Answer: Define secrets in the docker-compose.yml
file and reference them in services. Example:
version: '3.1'
services:
my_service:
image: my_image
secrets:
- my_secret
secrets:
my_secret:
file: ./my_secret.txt
78. What is the purpose of the docker rm
command?
Answer: The docker rm
command removes one or more stopped containers. It helps in cleaning up unused containers. Example:
docker rm my_container
79. How do you specify the user inside a Docker container?
Answer: Use the USER
instruction in the Dockerfile or the --user
flag with docker run
to specify the user. Example:
USER my_user
Or:
docker run --user my_user my_image
80. Explain the concept of Docker container linking.
Answer: Container linking is a legacy method to allow containers to communicate with each other. It involves using the --link
flag with docker run
to create a network connection between containers. This method is deprecated in favor of user-defined networks.
81. What is the purpose of the docker stop
command?
Answer: The docker stop
command stops a running container by sending a SIGTERM
signal, allowing the container to gracefully shut down. If the container does not stop within a timeout period, a SIGKILL
signal is sent. Example:
docker stop my_container
82. How do you build a Docker image without using the Dockerfile's cache?
Answer: Use the --no-cache
flag with docker build
to build an image without using the cache. This ensures that all instructions in the Dockerfile are executed from scratch. Example:
docker build --no-cache -t my_image .
83. What is the purpose of the docker volume inspect
command?
Answer: The docker volume inspect
command provides detailed information about a volume, such as its name, driver, and mount point. Example:
docker volume inspect my_volume
84. How do you limit the number of restarts for a Docker container?
Answer: Use the --restart
flag with docker run
and specify the maximum number of restart attempts using on-failure:<max-retries>
. Example:
docker run --restart on-failure:5 my_image
85. What is the purpose of the docker ps
command?
Answer: The docker ps
command lists running containers, showing details such as container ID, image, status, and ports. Example:
docker ps
86. How do you create a new Docker network with a specific driver?
Answer: Use the docker network create
command and specify the driver using the --driver
flag. Example:
docker network create --driver bridge my_network
87. What is the difference between docker start
and docker run
?
Answer:
docker run
: Creates and starts a new container from an image.docker start
: Starts an existing, stopped container.
88. How do you inspect the logs of a stopped Docker container?
Answer: Use the docker logs
command to view the logs of a stopped container. Example:
docker logs my_container
89. What is Docker Content Trust (DCT) and how is it enabled?
Answer: Docker Content Trust (DCT) is a security feature that ensures the authenticity and integrity of Docker images by signing and verifying them. Enable DCT by setting the DOCKER_CONTENT_TRUST
environment variable:
export DOCKER_CONTENT_TRUST=1
90. How do you remove a Docker image?
Answer: Use the docker rmi
command to remove one or more images. Example:
docker rmi my_image
91. What is the purpose of the docker swarm join-token
command?
Answer: The docker swarm join-token
command prints the join token for a worker or manager node, which can be used to add nodes to a swarm. Example:
docker swarm join-token worker
92. How do you configure DNS settings for a Docker container?
Answer: Use the --dns
flag with docker run
to specify custom DNS servers. Example:
docker run --dns 8.8.8.8 my_image
93. What is the purpose of the docker prune
commands?
Answer: Docker prune commands (docker container prune
, docker volume prune
, etc.) remove unused resources to free up space. Example:
docker container prune
94. How do you define a health check in a Docker Compose file?
Answer: Define a health check using the healthcheck
section in the docker-compose.yml
file. Example:
version: '3.1'
services:
my_service:
image: my_image
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost/health"]
interval: 1m30s
timeout: 10s
retries: 3
95. What is Docker Bench for Security and how is it used?
Answer: Docker Bench for Security is a script that checks for common best practices and security recommendations for Docker deployments. Run it to evaluate your Docker environment's security. Example:
docker run -it --net host --pid host --cap-add audit_control \
-v /var/lib:/var/lib -v /var/run/docker.sock:/var/run/docker.sock \
docker/docker-bench-security
96. How do you monitor Docker container metrics using Prometheus?
Answer: Use the Docker Exporter to expose container metrics to Prometheus. Configure the Docker daemon to enable metrics and then add the exporter as a target in Prometheus.
97. What is Docker Trusted Registry (DTR) and its purpose?
Answer: Docker Trusted Registry (DTR) is an enterprise-grade, private Docker image registry that provides image management and security features, such as image scanning and role-based access control. It integrates with Docker Enterprise for a comprehensive container management solution.
98. How do you back up Docker volumes?
Answer: Use the docker run
command to create a backup of a volume by copying its data to a tar archive. Example:
docker run --rm -v my_volume:/volume -v $(pwd):/backup alpine \
tar czf /backup/my_volume_backup.tar.gz -C /volume .
99. What is the purpose of the docker node update
command?
Answer: The docker node update
command updates the attributes of a node in a swarm, such as its availability and role. Example:
docker node update --availability drain my_node
100. How do you inspect the status of a Docker Swarm?
Answer: Use the docker node ls
command to view the status and roles of nodes in the swarm. Example:
docker node ls
Next Steps
Docker Books
Docker Interview Questions - Beginner Level
Docker Interview Questions - Medium Level Part 1
Docker Interview Questions - Medium Level Part 2
Docker Interview Questions - Advanced Level Part 1
Docker Interview Questions - Advanced Level Part 2
Docker Interview Questions - Advanced Level Part 3
Docker Interview Questions - Advanced Level Part 4
Share with friends