Beginner Docker & Kubernetes test (Beginner)
25 questions · 30 minutes · Free
Images, containers, Dockerfiles and first Kubernetes objects.
Take the Beginner Docker & Kubernetes test
What it covers
- Images and containers
- Writing a Dockerfile
- Volumes and networking
- Docker Compose
- Pods and deployments
Interview format
- Questions: 25 questions — 15 multiple choice, 10 multi-answer
- Time: 30 minutes, timed from the first question
- Difficulty: Beginner
- Skill area: DevOps & cloud
- Price: Free
Earn a certificate
The Beginner Docker & Kubernetes test is one of the 8 tests of the Backend Developer: Beginner learning path. Pass it and the other 7 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.
Sample questions
5 sample questions from the Beginner Docker & Kubernetes test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
When comparing NodePort and ClusterIP service types in Kubernetes, which statement accurately describes their use cases and when each should be chosen?
- NodePort service type is used for external communication, while ClusterIP is used for internal communication. NodePort is chosen for services that do not need external access, and ClusterIP is used when external access is required.
- NodePort service type is used to expose services on a specific port across all nodes in the cluster, while ClusterIP is used for internal communication within the cluster. NodePort is chosen when external access to the service is required, whereas ClusterIP is preferred for services that do not need external access.
- NodePort service type is used for internal communication within the cluster, while ClusterIP is used to expose services on a specific port across all nodes in the cluster. NodePort is chosen for services that do not need external access, whereas ClusterIP is preferred when external access is required.
- NodePort and ClusterIP are both used for internal communication within the cluster, and there is no difference between them in terms of exposing services externally.
Answer: B. NodePort service type is used to expose services on a specific port across all nodes in the cluster, while ClusterIP is used for internal communication within the cluster. NodePort is chosen when external access to the service is required, whereas ClusterIP is preferred for services that do not need external access.
NodePort is a Kubernetes service type that allows external traffic to reach a service by exposing it on a specific port on all nodes in the cluster. ClusterIP is used for internal communication within the cluster and is not accessible from outside the cluster. NodePort is chosen when external access is required, while ClusterIP is preferred for internal services.
What happens when you execute the following command: `docker run -v /host/data:/app/data myapp`?
- The volume is mounted at /app/data inside the container, but changes are not persisted and are lost upon container restart.
- The volume is mounted at /app/data inside the container, and any changes to this directory are persisted outside the container.
- The volume is not mounted at all, and the container uses a temporary directory instead.
- The volume is mounted at /app/data on the host machine, and changes are reflected inside the container but not outside.
Answer: B. The volume is mounted at /app/data inside the container, and any changes to this directory are persisted outside the container.
In Docker, when you use the `-v` or `--mount` flag with `docker run`, you specify the host path and the container path. Changes made to the container path are persisted to the host path, allowing data to survive container restarts or removals. Option 0 correctly describes this behavior. Options 1, 2, and 3 either describe incorrect behavior or misinterpret how volume mounting works.
In a Kubernetes Deployment YAML file, which of the following is the correct top-level field that defines the desired state of the Pods managed by the Deployment?
- template: { ... }
- spec: { ... }
- metadata: { ... }
- containers: [ ... ]
Answer: B. spec: { ... }
In a Kubernetes Deployment YAML file, the `spec` field is required and contains the desired state of the Pods managed by the Deployment. Other options like `metadata` or `template` are not directly used at the top level of the Deployment resource, and `containers` is a field within the `template` section, not at the top level.
Which Kubernetes service type is the default and creates a private IP address that is only accessible within the cluster?
- NodePort
- LoadBalancer
- ClusterIP
- ExternalName
Answer: C. ClusterIP
ClusterIP is the default service type in Kubernetes, and it creates a private IP address that is only accessible within the cluster. NodePort and LoadBalancer are other service types that expose services externally, but they are not the default. ExternalName is used to map a service to a DNS name outside the cluster.
When comparing host network mode and bridge mode in Docker, which of the following statements correctly describes their use cases and differences?
- Host network mode provides a virtual network for the container, while bridge mode allows a container to share the host's network stack.
- Host network mode and bridge mode are functionally identical and can be used interchangeably in all scenarios.
- Host network mode allows a container to share the host's network stack, making it suitable for scenarios where direct access to the host's interfaces is required, such as in cases involving network load balancers or when using specific drivers that require direct interface access. Bridge mode, on the other hand, creates a virtual network for the container, isolating it from the host's network stack and providing a more secure and isolated environment. Host mode is typically used in scenarios where network performance is critical, while bridge mode is used for general-purpose container networking.
- Host network mode is used for general-purpose container networking, while bridge mode is used for applications requiring direct access to the host's interfaces.
Answer: C. Host network mode allows a container to share the host's network stack, making it suitable for scenarios where direct access to the host's interfaces is required, such as in cases involving network load balancers or when using specific drivers that require direct interface access. Bridge mode, on the other hand, creates a virtual network for the container, isolating it from the host's network stack and providing a more secure and isolated environment. Host mode is typically used in scenarios where network performance is critical, while bridge mode is used for general-purpose container networking.
Host network mode provides direct access to the host's network stack, which is useful for certain applications but sacrifices isolation. Bridge mode provides a virtual network, which is more secure and isolated but may not be suitable for all use cases. The choice between the two depends on the specific requirements of the application and the environment.
Frequently asked questions
- How many questions are in the Beginner Docker & Kubernetes test?
- 25 questions (15 multiple choice, 10 multi-answer), with 30 minutes to answer them.
- What does the Beginner Docker & Kubernetes test cover?
- Images and containers, Writing a Dockerfile, Volumes and networking, Docker Compose, Pods and deployments.
- Is the Beginner Docker & Kubernetes test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Beginner Docker & Kubernetes test?
- Beginner, in DevOps & cloud.