{ "id": "docker-port-publish-mcq", "title": "Works Inside, Unreachable Outside", "category": "Containers", "isolation_type": "shared_namespace", "difficulty": "Medium", "type": "mcq", "weight": 4, "description": "## Works Inside, Unreachable Outside\n\nA web server container is confirmed healthy — `docker exec curl localhost:80` succeeds from inside it. But `curl http://localhost:8080/` from the HOST fails to connect. The container was started with plain `docker run -d myapp` (no other flags). What's most likely missing?", "options": [ { "id": "a", "text": "The image itself is broken" }, { "id": "b", "text": "A `-p 8080:80` port-publish flag was never set when the container was created, so nothing on the host maps to the container's port 80" }, { "id": "c", "text": "The container needs more memory" }, { "id": "d", "text": "DNS is misconfigured" } ], "correct_option": "b", "explanation": "Working correctly INSIDE the container proves the application itself is fine — the failure is specifically that the host has no mapping to the container's internal port. Port publishing (`-p hostPort:containerPort`) must be set at container creation time; without it, the container's ports are only reachable from other containers on the same Docker network, never from the host.", "hints": [], "setup_commands": [], "default_namespace": "default", "teardown_commands": [] }