Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Debug Docker Startup Exit
00:00
5 left

Debug Docker Startup Exit

MediumPython

Problem

What could be a common reason for Docker to automatically exit within seconds of starting?

Implement most_common_exit_reason(records) to analyze Docker container records and return the most frequent reason among containers that exit within 10 seconds. Each record is [duration_seconds, exit_code, foreground]; a non-foreground process indicates a daemon that was not kept running, exit code 0 indicates normal process completion, and any other exit code indicates a crash. Return "unknown" if no record qualifies. If counts tie, return the reason appearing first in the input.

Constraints

  • 1 <= records.length <= 10000
  • Each record contains exactly [duration_seconds, exit_code, foreground]
  • 0 <= duration_seconds <= 86400
  • -255 <= exit_code <= 255
  • foreground is a boolean
  • Only records lasting at most 10 seconds are considered

Function Signature

def most_common_exit_reason(records):
Interviewer

Your question is Debug Docker Startup Exit. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.