Docker (Coding) Assessment Test

Docker (Coding)

 60 Minutes
 3 Questions


This assessment requires candidates to write and run a Dockerfile that sets up an environment for a multi-service or multi-technology application. This environment may include a variety of components beyond just Node.js and MongoDB, such as databases, caching systems, message brokers, or specialized tools. The goal is to evaluate the candidate's ability to work with Docker to configure and manage complex containerized environments involving multiple technologies.


Example Question:

Coding
Docker Task: Create a Dockerfile for a Redis-Based Counter Service

In this task, you should write a Dockerfile for a Node.js counter API that utilizes Redis for data storage. Follow the instructions below to ensure the service runs correctly in a Docker container.

Requirements:

1. Base Image: Use node:16 as the base image for the Dockerfile.
2. Application Directory: Set the working directory to /usr/src/app.
3. Project Files: The folder containing the Dockerfile also includes:
  • counter.js: Contains the main code for the counter API.
  • package.json and package-lock.json: Specify the dependencies for the service.
4. Redis Setup: Install and configure Redis within the Docker container.
  • Redis should be set up to start when the container runs.
  • Set a password for Redis: Choose the following password "redis_password" and configure it in redis.conf using the requirepass option.
  • Redis should be set up to start and run locally within the container on port 6379.
5. Application Configuration:
Install all dependencies specified in package.json with npm install.
Configure the environment variable REDIS_URL in your Dockerfile to connect to Redis locally using the chosen password.
For example:
REDIS_URL=redis://:<redis_password>@127.0.0.1:6379
6. Expose Port: The container should expose port 8080, which will be mapped dynamically during runtime.
7. Run Command: The main process should start both Redis and the Node.js application using: