Here are some Docker Interview Questions with answers and/or links to answers. Good luck! 💪🤞
- What is .dockerignore?
- How it differs from .gitignore?
- Where is it usually located?
- How to ignore a directory?
- How to ignore all files in some directory but to include directory itself?
- Securing Docker Builds: A Comprehensive Guide to .dockerignore Usage and Best Practices | LinkedIn
- What is a Docker file?
- Which command each valid Dockerfile needs to start with?
- Explain Docker file command FROM.
- What does it do?
- Which is the only instruction that may precede FROM in the Dockerfile? Give an example.
- Explain multi-stage builds.
- Which 3 commands can refer to the build stage name?
- Dockerfile reference | Docker Docs
- Multi-stage builds | Docker Docs
- What is a base image?
- docker - Is `FROM` clause required in Dockerfile? - Stack Overflow
- I noticed the base image for a docker container doesn not have to be an Operating System, why? : r/docker
- Shrink to Secure: Kubernetes and Compact Containers
- linux - Why do we use a OS Base Image with Docker if containers have no Guest OS? - Server Fault
- Do all docker images have minimal OS? - Stack Overflow
- Are the images of full operating systems? - General Discussions - Docker Community Forums
- What is a scratch image?
- When is it used and how?
- Can it be pulled?
- scratch - Official Image | Docker Hub
- What is docker's scratch image? - Stack Overflow
- linux - How does docker scratch container run my app without a shell? - Unix & Linux Stack Exchange
- Can we run a C program without a Operating System? : r/compsci
- operating systems - Would an executable need an OS kernel to run? - Super User
- Explain Docker file command WORKDIR.
- If the path does not exist, will it be created?
- In case of multiple WORKDIR commands, how is the final path calculated?
- Dockerfile reference | Docker Docs
- Which piece of information is used to resolve (local) paths in COPY and ADD instructions in the Dockerfile?
- Explain Dockerfile command ADD.
- How to instruct Dockerfile to download a file from a given URL and save it in a given location in the image?
- Explain Dockerfile command COPY.
- What are its arguments?
- How are relative paths resolved?
- What's the use case for COPY in Dockerfile and what's use case for volume attribute in docker-compose.yaml (or in docker run)? Which one is used in development and which one in production and why?
- How to copy files or directories from another docker image?
- Explain Docker file command RUN.
- Explain Docker file command CMD.
- What is the difference between RUN, CMD and ENTRYPOINT?
- Explain Docker file command ENV. How does docker run -e differ from it?
- How to set env variable to the value of some argument ARG1 if ARG1 is set and to some arbitrary string otherwise?
- Dockerfile reference | Docker Docs
- Dockerfile reference | Docker Docs
- docker run | Docker Docs
- How to create a directory in Docker image? Which Docker file command shall be used?
- Explain Docker file command EXPOSE.
- What can be created so containers don't need to expose or publish ports for their communication?
- Dockerfile reference | Docker Docs
- Explain Dockerfile command USER
- Why is not specifying USER a security risk?
- dockerfile - What does it do when we defines USER in docker file - Stack Overflow
- Understanding the Docker USER Instruction | Docker
- Explain docker run --user command.
- Does Docker respect current ownership of the existing directories which are mounted onto containers as volumes?
- Understanding the Docker USER Instruction | Docker
- Is it possible to use variables in Dockerfile?
- How to create a Docker image?
- Which Docker command shall be used? Which are its two main arguments?
- What is the "build context"?
- Can a Dockerfile with arbitrary name be used? How?
- What's the meaning of its arguments: -t, -f?
- Explain the full image name structure.
- Build, tag, and publish an image | Docker Docs
- Explain docker build cache
- Give some examples how to make building Docker image faster.
- Docker build cache | Docker Docs
- Does docker build command use --name or --tag argument?
- How to print debug messages during docker build?
- How to download Docker image from the remote repository?
- What are the long and short form of the command used?
- Which tag gets applied if no tag is specified?
- How many layers are downloaded in parallel by default?
- Can layers be shared among multiple images?
- Where are these images downloaded to?
- Where from are the images downloaded from by default?
- How would look the command that pulls the image from the local registry?
- Which protocol does Docker use to communicate with registry?
- How to pull multiple images from a repository?
- How to cancel downloading image(s)?
- docker pull | Docker Docs
- How to list all images (on the local host)?
- What are the long and short form of the command used?
- docker images | Docker Docs
- How to see the content of the Docker image?
- Is that the same as inspecting the content of the container?
- What is the benefit of inspecting the content of the image?
- How to see docker image contents - Stack Overflow
- How to list all running containers?
- How to list all containers?
- How to list all containers (including those which are not running)?
- How to inspect a container?
- How to extract only its ID?
- How to extract details about ports which are at this level in the JSON output: NetworkSettings >> Ports?
- Whose alias is docker run?
- What does it do?
- What is its main argument?
- In which state is the container after this command is executed?
- Explain -i option. Which application running in container is affected and how?
- Explain -t option.
- Explain -d option.
- Explain -v option.
- Explain -w option.
- Explain --rm option.
- Explain --name option.
- docker run | Docker Docs
- dockerfile - what is docker run -it flag? - Stack Overflow
- How to get the interactive terminal which is waiting for user input if we are running Docker container based on Linux which has /bin/bash? Write the full command.
- Whose alias is docker create?
- What does it do?
- What is its main argument?
- In which state is the container after this command is executed?
- How to start the container after this?
- docker create | Docker Docs
- Is it possible to rename a container?
- docker-compose up
- What is the difference between --build and --force-recreate arguments?
- How to run a container based on alpine Linux which writes current timestamp into /var/log/date.log every 2 seconds?
- Why would we want to execute a command in the running container?
- How to start an interactive shell (with opening up a pseudo-terminal) inside a Docker Container?
- How to exit back out of the container?
- How to run a non-interactive shell inside a Docker container?
- How to run commands in an alternate directory in a Docker container?
- How to run commands as a different user in a Docker container?
- How to pass environment variables into a Docker container?
- How To Use docker exec to Run Commands in a Docker Container | DigitalOcean
- How to run multiple processes in the container?
- Which 4 Docker object types can be pruned?
- How to prune all unused objects?
- Prune unused Docker objects | Docker Docs
- What is an unused and what is a dangling Docker image?
- Which command removes only dangling images?
- How to remove all images which aren't used by existing containers?
- Prune unused Docker objects | Docker Docs
- docker - What is a dangling image and what is an unused image? - Stack Overflow
- How to delete local Docker image?
- Are containers automatically removed once they are stopped?
- How to remove all stopped containers?
- Prune unused Docker objects | Docker Docs
- What is the difference between docker compose file and Dockerfile?
- What's the difference between Docker Compose vs. Dockerfile - Stack Overflow
- Docker Compose vs. Dockerfile with Code Examples |
- Dockerfile vs docker-compose: What's the difference?
- Explain Docker Compose specification attribute: image
- Explain Docker Compose specification attribute: build
- How to set the name of the Docker image built with docker compose up?
- What's the meaning of its attributes:
- context
- dockerfile. How is it used together with context?
- dockerfile_inline
- args
- ssh
- cache_from
- cache_to
- additional_contexts
- extra_hosts
- isolation
- privileged
- labels
- no_cache
- pull
- network
- shm_size
- target
- secrets
- tags
- ulimits
- platforms
- Can both build and image be specified for the same service?
- Compose Build Specification | Docker Docs
- Does docker compose require Dockerfile? (Can docker compose file replace Dockerfile?)
- Explain Docker Compose specification attribute: ports
- Explain Docker Compose specification attribute: volumes
- Explain Docker Compose specification attribute: networks
- Explain Docker Compose specification attribute: command
- How to specify a Docker network in Docker Compose specification?
- Explain Docker Compose specification network's attribute: driver
- Explain command: docker compose up
- How to check the commands used to create each Docker image layer and also the size of each layer?
- To Be Continued...
No comments:
Post a Comment