Docker Interview Questions Answer 1733740881
Docker Interview Questions Answer 1733740881
• Engine: The Docker Engine is the core component that runs on the host OS,
allowing users to build, run, and manage containers.
• COPY: Only copies files and directories from the host filesystem into the image.
• ADD: More versatile; it can also copy files from URLs and automatically extract
compressed files.
• CMD: Sets the default command that will run when a container starts. Only one
CMD command is used per Dockerfile, and it can be overridden.
• RUN: Executes a command at build time and creates a new image layer. Used to
install packages and set up the environment.
• Docker Daemon: Runs on the host and manages images, containers, networks,
and volumes.
• Docker Registry: Stores Docker images; Docker Hub is the default registry.
7. Explain the terminology
9. Docker vs Hypervisor
• Docker containers are lightweight and share the host OS, while hypervisors run
full OS VMs. Containers are faster and more resource-efficient, but VMs provide
stronger isolation.
• A storage location for Docker images. The default registry is Docker Hub, where
users can push and pull images.
15. Will data on the container be lost when the Docker container exits?
• Yes, unless data is stored in volumes, which are independent of the container's
lifecycle.
• Run a container under a specific name: docker run --name <name> <image>
• Check logs with docker logs <container-id>, inspect the configuration, verify port
bindings, and check Dockerfile for errors.
• Use Docker volumes or bind mounts to persist data outside the container,
ensuring it remains even if the container is removed.
• Pass environment variables at runtime with -e VAR=VALUE or using .env files, and
reference them in the Dockerfile or Docker Compose configuration.