Docker commands#
Show containers#
To show the list of launched Docker containers use the command:
docker ps
To show all the existing Docker containers use the command:
docker ps -a
Copy files to container#
You can transfer files into the container. Use the docker cp
command to copy a file into the container.
docker cp <file_location> <container_name>:<folder_inside_container>
Enter container#
You can enter individual containers using the following command:
docker exec -it <container_name> bash
To exit the container, use the command:
exit
Images names#
You can see all the names of the images using the command
docker images
Show container logs#
You can view the container logs with the following command:
docker logs <container_name>
Delete image#
If you need to delete an image:
- run the
docker images
command - find the required image, for example: dockerhub.visionlabs.ru/luna/v.5.1.14
- copy the corresponding image ID from the IMAGE ID, for example, \"61860d036d8c\"
- specify it in the deletion command:
docker rmi -f 61860d036d8c
Delete all the existing images:
docker rmi -f $(docker images -q)
Stop container#
You can stop the container using the command:
docker stop <container_name>
Stop all the containers:
docker stop $(docker ps -a -q)
Delete container#
If you need to delete a container:
- run the
docker ps
command - stop the container (see Stop container)
- find the required image, for example: dockerhub.visionlabs.ru/luna/v.5.1.14
- copy the corresponding container ID from the CONTAINER ID column, for example, "23f555be8f3a"
- specify it in the deletion command:
docker container rm -f 23f555be8f3a
Delete all the containers:
docker container rm -f $(docker container ls -aq)