docker:run-stop-containers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
docker:run-stop-containers [2024/02/19 23:20] – removed - external edit (Unknown date) 127.0.0.1 | docker:run-stop-containers [2024/02/23 19:40] (current) – odefta | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== | ||
+ | |||
+ | < | ||
+ | docker ps | ||
+ | </ | ||
+ | Output: | ||
+ | < | ||
+ | e26c2dcdc6a0 | ||
+ | b8a3da1af510 | ||
+ | 32bdc9aabb3f | ||
+ | e319f3296383 | ||
+ | 42b90dc323ee | ||
+ | </ | ||
+ | |||
+ | ====== Display all docker containers ====== | ||
+ | |||
+ | < | ||
+ | docker ps -a | ||
+ | </ | ||
+ | |||
+ | ====== Connect to an existing running container to execute commands ====== | ||
+ | |||
+ | -it accepts container id or name | ||
+ | < | ||
+ | docker exec -it b1faf04f660b bash | ||
+ | </ | ||
+ | |||
+ | ====== Run a docker container ====== | ||
+ | |||
+ | < | ||
+ | docker run --name hello-world registry.git.dovsoft.com/ | ||
+ | </ | ||
+ | Hello World | ||
+ | |||
+ | ===== Run a container and connect to shell ===== | ||
+ | |||
+ | To connect to the image shell and interact (i) with terminal (t), run: | ||
+ | < | ||
+ | docker run -it ubuntu /bin/bash | ||
+ | </ | ||
+ | Output: | ||
+ | < | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | 01007420e9b0: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for ubuntu: | ||
+ | root@3a91f4539cc3:/# | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | If no registry is specified, the docker command will search in Docker Hub (https:// | ||
+ | </ | ||
+ | |||
+ | ====== Stop a running docker container ====== | ||
+ | |||
+ | Enter the name or the ID of the container. | ||
+ | < | ||
+ | docker stop compassionate_galois | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | docker stop 3a91f4539cc3 | ||
+ | </ | ||
+ | |||
+ | ===== Stop all running docker containers ===== | ||
+ | |||
+ | For linux: | ||
+ | < | ||
+ | docker stop $(docker ps -q) | ||
+ | </ | ||
+ | |||
+ | For windows (power shell): | ||
+ | < | ||
+ | docker ps -q | ForEach-Object {docker stop $_} | ||
+ | </ | ||
+ | |||
+ | For windows (cmd): | ||
+ | < | ||
+ | FOR /f " | ||
+ | </ | ||