Câu hỏi phỏng vấn Docker
Câu hỏi

What are the various states that a Docker container can be in at any given point in time?

Câu trả lời

A Docker container can be in several states throughout its lifecycle. These states represent the different phases a container goes through from creation to termination. Here are the various states a Docker container can be in at any given point in time:

  1. Created: This is the initial state of a Docker container after it has been created but before it has been started. The container is set up but not yet running any processes.

    • Command: docker create --name <name-of-container> <docker-image-name> [1][3][5][6].
  2. Running: When a Docker container is started, it transitions to the running state. In this state, the container is actively executing its processes.

    • Command: docker start <container-id> or docker run <container-id> [1][3][5][6].
  3. Paused: In this state, the container's processes are temporarily stopped, but the container itself is not terminated. This is useful for temporarily halting the container's activity without stopping it completely.

    • Command: docker pause <container-id> [1][3][5][6].
  4. Unpaused: This state occurs when a paused container is resumed and continues executing its processes.

    • Command: docker unpause <container-id> [1][3].
  5. Stopped: The container's main process is shut down gracefully. This state is reached when the container has been stopped but not yet removed.

    • Command: docker stop <container-id> [1][3][5][6].
  6. Exited: This state indicates that the container has completed its execution and has stopped, typically after successfully running a command or task.

    • Command: This state is automatically reached after the container's main process exits [5][6].
  7. Dead: If a container fails to start or encounters a critical error, it enters the dead state. Containers in this state cannot be restarted and must be recreated.

    • Command: This state...
junior

junior

Gợi ý câu hỏi phỏng vấn

middle

What is the preferred way of removing containers - ‘docker rm -f’ or ‘docker stop’ then followed by a
‘docker rm’?

middle

What is the difference between CMD and ENTRYPOINT in a Dockerfile?

middle

What is the default CPU limit set for a container?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào