Guest User

Untitled

a guest
Jul 19th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. # Docker cool commands
  2.  
  3. ## Tail logs
  4.  
  5. In the first steps of an app you can not configure graylog or complex log processing tools.
  6. Search in docker logs is easy:
  7.  
  8. docker logs -t --tail 1000 my_container
  9.  
  10. docker logs -t --tail 1000 my_container 2>&1 | grep -i error
  11.  
  12. In previous example we are searching for error (case-insensitive) in the last 1000 log lines.
  13.  
  14. ## Docker postgres/postgis backup
  15.  
  16. Docker backup command
  17.  
  18. docker exec -it --env PGPASSWORD=[POSTGRESQL_PASSWORD] database_container pg_dump \
  19. -h [POSTGRESQL_HOST] -p [POSTGRESQL_PORT] \
  20. -U [POSTGRESQL_USER] [POSTGRESQL_DATABASE] | gzip -9 > backup.sql.gz
  21.  
  22. ## Copy file from host to container
  23.  
  24. Simple file copy:
  25.  
  26. docker cp script.js container_name:/app/
  27.  
  28. ## Copy file from container
  29.  
  30. Simple file copy:
  31.  
  32. docker cp container_name:/app/. .
  33.  
  34. ## Cron task in docker-compose
  35.  
  36. Configuration for run cron tasks in docker. In this example, scripts in cron_tasks_folder will be executed hourly:
  37.  
  38. version: '3'
  39. services:
  40. cron:
  41. image: alpine:3.6
  42. command: crond -f -l 8
  43. volumes:
  44. - ./cron_tasks_folder:/etc/periodic/hourly/:ro
  45.  
  46. ## Remove all unused images
  47.  
  48. Be carefoul with this commands!!!
  49. Command to remove all unused images:
  50.  
  51. docker image prune -a
  52.  
  53. Command to remove dangling images:
  54.  
  55. docker rmi $(docker images -q -f dangling=true)
  56.  
  57. Docker has a command to delete all stopped containers, dangling images, networks, unused volumes and build cache at the same time:
  58.  
  59. docker system prune -a --volumes
Add Comment
Please, Sign In to add comment