📅  最后修改于: 2023-12-03 15:14:45.664000             🧑  作者: Mango
Docker is a powerful tool that allows users to create, run, and manage containers. However, as a programmer, you may encounter a situation where you need to exit a Docker container in the Shell/Bash command line. This guide will detail the steps to exit a Docker container in Shell/Bash.
To exit a Docker container in Shell/Bash, you can use the exit
command followed by the container ID or name.
docker ps
command to list all running containers and their ID:$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c02751d3c360 nginx:latest "/nginx..." 5 minutes ago Up 5 minutes 80/tcp nginx_container
Copy the container ID of the container that you want to exit.
Now, use the following command to exit the container:
$ docker container exit [container ID]
$ docker container exit [container name]
Exiting a Docker container in Shell/Bash is a simple process that can be accomplished using the exit
command followed by the container ID or name. These commands provide a quick and efficient way to exit a container from the Shell/Bash command line.