Skip to content

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

Delete image#

If you need to delete an image:

  • run the docker images command
  • find the required image, for example dockerhub.visionlabs.ru/luna/luna-image-store
  • 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/luna-image-store
  • 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)

Service logs#

All the services are writing logs. The logs are saved for each service in its container.

They are saved in the "srv/" directory and have the following names:

_ERROR.txt

_INFO.txt

Check service logs#

When launching Docker as a daemon, logs will be sent to a separate file. You can use the following command to show logs for the service:

docker logs <container_name>