Skip to main content
InterviewHubPRO
Section Overview
Q10

Question 10 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

20%
Docker & Containers (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

How do you view container logs, inspect container state, and open an interactive shell inside a running container?

junior LevelCode ExampleDocker & Containers

In Simple Words:

  1. Interactive Shell:
    bash
    # Executes an interactive Bash or Sh terminal inside running container
    docker exec -it <container_id_or_name> /bin/sh
    
  2. Viewing Live Logs:
    bash
    # Streams live output and timestamps from stdout/stderr of PID 1
    docker logs -f --tail 100 <container_name>
    
  3. Inspecting Low-Level JSON Metadata:
    bash
    # Prints IP address, mount points, environment variables, health status
    docker inspect <container_name>
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_name>