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:
- Interactive Shell:
bash
# Executes an interactive Bash or Sh terminal inside running container docker exec -it <container_id_or_name> /bin/sh - Viewing Live Logs:
bash
# Streams live output and timestamps from stdout/stderr of PID 1 docker logs -f --tail 100 <container_name> - 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>