How to clear a docker desktop container log

Something happened to my container while I was viewing the log in the docker desktop container log window and the log file was busy writing its contents to the window i decided I would try to click the clear terminal button as it was taking forever to write out all the log files contents into the window but then I was presented with an error in the log file not sure whether this is coincidental.

error from daemon in stream: Error grabbing logs: invalid character ‘l’ after object key:value pair

I have done some research to see how I can fix the corrupted log file in my container.

docker inspect Uptime | grep log

Presents me with the log path

When I try to run the following command replacing MyContainerID with the ID and with the container name

sudo sh -c ‘echo “” > $(docker inspect --format=“{{./var/lib/docker/containers/MyContainerID/MyContainerID-json.log
}}” )’

I get:

template parsing error: template: :1: bad character U+002F ‘/’
sh: 1: cannot create : Directory nonexistent

From what i read this is because docker desktop does not store its image file on the host but rather in the container?

If that is the case how do i clear a containers logs in docker desktop environment?

I tried to enter into the container
docker exec -it bash

And run the same command to clean the log file I am presented with the same error.

If I stop the docker service I obviously cannot enter into the container anymore but the command still fails from terminal on the host with the same error.

Hoping someone can tell me how I can clean a corrupted log file of a container on docker desktop.

Thank you

Could be a bug since there is another issue here with the same error message: