General Flashcards
What is Docker?
Docker is an open platform for developing, shipping, and running applications in containers.
What are Docker containers?
Docker containers are lightweight, standalone, executable packages that include everything needed to run a piece of software, including the code, runtime, libraries, and settings.
How does Docker differ from virtual machines?
Docker containers share the host system’s kernel and resources, making them more lightweight and efficient compared to virtual machines, which require a full OS instance for each VM.
What command is used to list all Docker containers?
The command is ‘docker ps’ for running containers and ‘docker ps -a’ for all containers. PS stands for “Process Status”
What file is used to define a multi-container Docker application?
A Docker Compose file, usually named ‘docker-compose.yml’, is used to define multi-container Docker applications.
How do you build a Docker image from a Dockerfile?
Use the command ‘docker build -t image_name .’, where ‘image_name’ is your desired image name and ‘.’ specifies the current directory containing the Dockerfile.
What is the purpose of a Dockerfile?
A Dockerfile is a script containing a series of instructions on how to build a Docker image.
What command is used to start a Docker container?
The command is ‘docker run’.
How do you remove a Docker container?
Use the command ‘docker rm container_id’, where ‘container_id’ is the ID of the container you want to remove.
What command is used to stop a running Docker container?
The command is ‘docker stop container_id’, where ‘container_id’ is the ID of the running container.
How can you view the logs of a Docker container?
Use the command ‘docker logs container_id’.
What is Docker Hub?
Docker Hub is a cloud-based repository where Docker users can create, test, store, and distribute container images.
How do you pull an image from Docker Hub?
Use the command ‘docker pull image_name’.
What is the purpose of the ‘docker-compose up’ command?
The ‘docker-compose up’ command starts and runs the entire application as defined in the ‘docker-compose.yml’ file.
How do you share data between Docker containers?
You can share data between Docker containers using Docker volumes.
What is a Docker volume?
A Docker volume is a storage mechanism that allows data to persist beyond the lifecycle of a container.
How do you create a Docker network?
Use the command ‘docker network create network_name’.
What is the purpose of Docker Swarm?
Docker Swarm is a native clustering and orchestration tool for Docker, enabling the management of a cluster of Docker nodes as a single virtual system.
How do you update a service in Docker Swarm?
Use the command ‘docker service update service_name’.
What is the purpose of the ‘EXPOSE’ instruction in a Dockerfile?
The ‘EXPOSE’ instruction informs Docker that the container listens on the specified network ports at runtime.
What is the ‘ENTRYPOINT’ instruction in a Dockerfile?
The ‘ENTRYPOINT’ instruction specifies the command that will run when a container is started from the image.
What is the difference between ‘CMD’ and ‘ENTRYPOINT’ in a Dockerfile?
‘CMD’ provides default arguments for the ‘ENTRYPOINT’ instruction, whereas ‘ENTRYPOINT’ defines the main command to run in the container.
How do you restart a stopped Docker container?
Use the command ‘docker start container_id’.
What command is used to remove a Docker image?
The command is ‘docker rmi image_id’, where ‘image_id’ is the ID of the image you want to remove.
How do you list all Docker images on your system?
Use the command ‘docker images’.
What is the ‘docker exec’ command used for?
The ‘docker exec’ command is used to run a command in a running container.
How can you check the resource usage of Docker containers?
Use the command ‘docker stats’.
What is the purpose of the ‘VOLUME’ instruction in a Dockerfile?
The ‘VOLUME’ instruction creates a mount point with the specified path and marks it as holding externally mounted volumes from native host or other containers.
How do you preview the details of a Docker container?
Use the command ‘docker inspect container_id’.
What is a Docker registry?
A Docker registry is a storage and distribution system for Docker images.
How can you limit the memory usage of a Docker container?
Use the ‘–memory’ flag with ‘docker run’, e.g., ‘docker run –memory=512m container_name’.
What is the ‘FROM’ instruction in a Dockerfile?
The ‘FROM’ instruction specifies the base image to use for the Docker image being built.
What is the use of ‘WORKDIR’ in a Dockerfile?
The ‘WORKDIR’ instruction sets the working directory for any subsequent instructions in the Dockerfile.
How do you attach to a running Docker container?
Use the command ‘docker attach container_id’.
What is the purpose of the ‘.dockerignore’ file?
The ‘.dockerignore’ file is used to specify files and directories to exclude from the Docker build context, similar to a ‘.gitignore’ file.
How do you copy files from the host system to a Docker container?
Use the ‘docker cp’ command, e.g., ‘docker cp host_path container_id:container_path’.
What is the ‘LABEL’ instruction in a Dockerfile?
The ‘LABEL’ instruction adds metadata to an image, such as a description, version, or maintainer.
How do you rename a Docker container?
Use the command ‘docker rename old_name new_name’.
What is Docker’s default network driver?
Docker’s default network driver is ‘bridge’.
How do you run a Docker container in the background?
Use the ‘-d’ flag with ‘docker run’, e.g., ‘docker run -d container_name’.