Let us take a look at how to stop and start a docker container,
First let's create a container using the docker run command,
% docker run -id --name my_alpine alpine
a7fdf87c9868281057018c20cbfcaa0c8108214b4f2a151ff9f22d8627774c38
Let's see the details of the running docker containers using the docker ps command,
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a7fdf87c9868 alpine "/bin/sh" 53 seconds ago Up 52 seconds my_alpine
Stop a docker Container
To stop a docker container make use of the command docker stop followed by the CONTAINER ID or the name of the docker container,
Example:% docker stop my_alpine
my_alpine
Let's see if got stopped with the docker ps command again, but this time with a -a option,
% docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a7fdf87c9868 alpine "/bin/sh" 24 minutes ago Exited (137) 1 minutes ago my_alpine
Start a Start a stopped Docker Container
As you may have guessed we can start a stopped/exited container using docker start <container_name or id>
% docker start a7fdf87c9868
a7fdf87c9868
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a7fdf87c9868 alpine "/bin/sh" 28 minutes ago Up 2 minutes my_alpine
Facing issues? Have Questions? Post them here! I am happy to answer!
- Install Docker on Mac using brew cask
- How to know the Docker Sandbox ID of a Container Network?
- How to Rename Docker Image with none TAG and REPOSITORY?
- How to know list of images available on your device
- Docker Alpine Linux and Apache2 Example
- Install Bash on Alpine Linux - Docker
- Docker Run Command Examples - Part 1
- Install the minimal Linux on Docker (only 5 mb Alpine Linux)
- [fix] docker: Error response from daemon: dial unix docker.raw.sock: connect: no such file or directory.
- Install RabbitMQ on Docker
- How to know docker Engine details
- [Fix] Docker Error response from daemon: manifest for :latest not found: manifest unknown
- How to stop and start a docker container
- How to create volume in Docker using Command
- How to know the Docker Engine Version
- [docker] Error response from daemon: No such container
- Install Docker for Mac using Home-brew Cask
- Docker - Incompatible CPU detected - M1/M2 Mac (macOS Sonoma)
- [fix] Docker Desktop App not starting on Mac (macOS)
- Unable to find image docker latest locally
- How to Stop/Cancel/kill docker image pull
- List of what's new in Docker 4.23
- [Docker M1/M2 Mac] qemu-x86_64: Could not open /lib64/ld-linux-x86-64.so.2: No such file or directory AWS CLI
- Install Docker Desktop on M1/M2 Apple Silicon ARM Chip Mac
- Docker - Running in Resource Saver mode
- PowerShell Switch Statement with Examples - Powershell
- Convert Map to List in Java 8 using Stream API - Java
- macOS App is damaged and cant be opened. You should move it to the Trash. - HowTos
- SharePoint update append Required Field to display name of mandatory columns - SharePoint
- Maven Central Repository: URL and Details - Java
- Compare Current and Previous Versions of Same File (Local History) in Eclipse - Eclipse
- Calculate Volume of Ellipsoid - C-Program
- Fix 0x80070194 Error When Opening Microsoft OneDrive File - Microsoft