Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Docker cool commands
- ## Tail logs
- In the first steps of an app you can not configure graylog or complex log processing tools.
- Search in docker logs is easy:
- docker logs -t --tail 1000 my_container
- docker logs -t --tail 1000 my_container 2>&1 | grep -i error
- In previous example we are searching for error (case-insensitive) in the last 1000 log lines.
- ## Docker postgres/postgis backup
- Docker backup command
- docker exec -it --env PGPASSWORD=[POSTGRESQL_PASSWORD] database_container pg_dump \
- -h [POSTGRESQL_HOST] -p [POSTGRESQL_PORT] \
- -U [POSTGRESQL_USER] [POSTGRESQL_DATABASE] | gzip -9 > backup.sql.gz
- ## Copy file from host to container
- Simple file copy:
- docker cp script.js container_name:/app/
- ## Copy file from container
- Simple file copy:
- docker cp container_name:/app/. .
- ## Cron task in docker-compose
- Configuration for run cron tasks in docker. In this example, scripts in cron_tasks_folder will be executed hourly:
- version: '3'
- services:
- cron:
- image: alpine:3.6
- command: crond -f -l 8
- volumes:
- - ./cron_tasks_folder:/etc/periodic/hourly/:ro
- ## Remove all unused images
- Be carefoul with this commands!!!
- Command to remove all unused images:
- docker image prune -a
- Command to remove dangling images:
- docker rmi $(docker images -q -f dangling=true)
- Docker has a command to delete all stopped containers, dangling images, networks, unused volumes and build cache at the same time:
- docker system prune -a --volumes
Add Comment
Please, Sign In to add comment