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>

Write logs to directory#

You can configure LP services to write logs to the directory outside of the container.

Logs for each container are saved to the "/tmp/logs" directory by default. You can change the directory using this method.

The example, is given for the API service.

Create the directory for logs on your server, for example:

mkdir -p /var/lib/luna/logs/luna-api-logs

If the container was already launched, you must delete it using the command from the "Delete container" section.

Next you must start the container with the following additional command -v /var/lib/luna/current/logs/luna-api-logs:/srv/log. Here you must specify the created folder for logs.

docker run \
--env=CONFIGURATOR_HOST=127.0.0.1 \
--env=CONFIGURATOR_PORT=5070 \
--env=PORT=5000 \
-v /var/lib/luna/logs/luna-api-logs:/srv/logs \
-v /etc/localtime:/etc/localtime:ro \
--name=luna-api \
--restart=always \
--detach=true \
--network=host \
dockerhub.visionlabs.ru/luna/luna-api:v.3.1.7

Thus you can specify the directory for each of the LP services.