Docker_Interview1
Docker_Interview1
Docker Scenario-based
Interview Questions
4. How can you transfer files from your local system to a Docker container?
6. What command would you use to remove all stopped Docker containers?
o Answer: Using the -p or --publish flag with the docker run command. For
example:
o docker run -p 8080:80 my_container
o Answer: Docker volumes are persistent data storage mechanisms that exist
outside the container's lifecycle. They are crucial for persisting data between
container restarts and for sharing data between containers.
o Answer: Using the -v or --volume flag with the docker run command. For
example:
o docker run -v /host/directory:/container/directory my_container
o Answer: Using the docker network create command with the --driver
overlay option. For example:
o docker network create --driver overlay my_overlay_network
o Answer: Docker logging drivers determine where container logs are sent and
how they are formatted. They allow you to customize log handling based on
your application's needs.
o Answer: Using the --log-driver option with the docker run command. For
example:
o docker run --log-driver=syslog my_container
o Answer: Docker health check is a feature that allows you to monitor the
health of a container and take action based on its status. It helps ensure the
reliability and availability of your applications.
25. How do you remove unused Docker images from your system?
o Answer: Docker content trust is a security feature that allows you to verify the
integrity and authenticity of Docker images. It helps prevent the execution of
tampered or malicious images.
configurations, and using diagnostic tools like docker stats and docker inspect.
o Answer: Docker Engine is the core component of Docker that runs and
manages Docker containers. It includes a server (daemon), REST API, and
command-line interface.
o Answer: Best practices include using trusted base images, minimizing the
attack surface, using Docker security features like content trust and user
namespaces, and regularly updating Docker components.
o Answer: Docker volumes are managed by Docker and persist data outside the
container's lifecycle. Bind mounts link a directory or file on the host machine
to a directory in the container and are subject to filesystem permissions.
41. Explain Docker CPU and memory constraints and how to set them.
o Answer: Docker CPU and memory constraints limit the amount of CPU and
memory a container can use. You can set them using the --cpus and --
memory options with the docker run command.
44. Explain Docker build caching and how it improves build performance.
o Answer: Docker build caching caches intermediate layers during the image
build process. It improves build performance by reusing cached layers for
unchanged build steps.
o Answer: Using the --restart option with the docker run command. For
example:
o docker run --restart=always my_container
49. What is Docker swarm mode, and how does it differ from standalone
Docker?