Docker Commands

Docker ralated kill/create/tag commands
Continue updating …

show containers

1
2
3
docker ps      # show running containers
docker ps -a # show all containers
docker ps -q # Only display numeric IDs, quiet

stop containers

1
2
docker stop *  # Stop one or more running containers
docker stop $(docker ps -aq) # stop all containers
1
2
3
docker container ls  # list all containers
docker container prune # remove all stopped containers
docker container kill CONTAINER-NAME # kill containers

system ralated

1
2
3
4
5
docker system prune             # Remove unused data
docker system prune --volumes # prune volumes
docker system df # Show docker disk usage
docker system events # Get real time events from the server
docker system info # Display system-wide information

system image ralated

1
2
3
docker images                   # list images
docker image ls # list images
docker image prune # remove unused images

run bash command from one running container

1
docker exec it DOCKER_NAME /bin/bash

docker volumes ralated

1
2
docker volume ls                # list volumes
docker volume prune # remove all unused volumes

To display logs:

1
2
Copydocker container logs <container>
docker logs <container>
  • You can stream the log output using -f (or –follow):
1
ocker logs -f <container>

Type Ctrl+C to exit.

Most containers generate a lot of entries, so you can use the –tail or –until options to limit the amount. For example, to display only the last 20 log entries:

1
docker logs -f --tail 20 <container>