### Create Bash script
You may simple use the following code to save as a bash script to clear docker log.
```sh
#!/bin/bash -e
if [[ -z $1 ]]; then
echo "No container specified"
exit 1
fi
if [[ "$(docker ps -aq -f name=^/${1}$ 2> /dev/null)" == "" ]]; then
echo "Container \"$1\" does not exist, exiting."
exit 1
fi
log=$(docker inspect -f '{{.LogPath}}' $1 2> /dev/null)
truncate -s 0 $log
```
### Usage
Use `docker ps` to list each docker container and find their id's.
```sh
$ docker ps
```
Clear docker log by provide docker name as first parameter of the script.
```sh
$ ./docker-clear-log my-nginx-container
```
Enjoy : )