Reputation: 2472
I upgraded my Docker version to the latest one and I got this error:
error from daemon in stream: Error grabbing logs: invalid character '\x00' looking for beginning of value
I can’t read logs using:
docker-compose logs -f myservice
nor with:
docker logs -f 6f454c73ff9c
Output of Docker version:
Client:
Version: 17.09.0-ce
API version: 1.32
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:42:18 2017
OS/Arch: linux/amd64
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:40:56 2017
OS/Arch: linux/amd64
Experimental: false
Output of Docker info:
Containers: 11
Running: 11
Paused: 0
Stopped: 0
Images: 8
Server Version: 17.09.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 76
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-97-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.695GiB
Name: egmintel-desktop
ID: VB22:IXWI:GY6D:QPM4:SPHX:HYUP:OQN7:ZM55:LLKE:P3UU:XK7F:26TH
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
My docker-compose version:
docker-compose version 1.16.1, build 6d1ac21
I also noticed that one of my containers is not working properly (but I can't see the error since I can't read logs) and I need to restart the Docker service so my container starts working again.
Any ideas how to solve this? Thanks!
Upvotes: 51
Views: 97146
Reputation: 119
You can use Portainer to see/copy/download the logs without errors. See my full guide here
Upvotes: 0
Reputation: 1
Rotate logs
Move the current log file to a backup file and restart Docker.
echo “Rotating the log file...”
sudo mv $LOG_PATH ${LOG_PATH}.bak
sudo systemctl restart docker
or
sudo service docker restart
echo “Docker restarted and log file rotated.”
Upvotes: 0
Reputation: 2497
A workaround that work's : --tail=10 flag (or whatever number you like) to only get the lines after the "invalid" character.
docker logs --tail=10
it work also with docker compose
found here https://github.com/docker/for-linux/issues/140#issuecomment-374930251
Upvotes: 5
Reputation: 246
you can clear your docker log with this:
cat /dev/null > $(docker inspect --format='{{.LogPath}}' YOUR_DOCKER_CONTAINER_NAME_HERE)
Upvotes: 6
Reputation: 81
This command will remove all \x00 bytes from all docker containers log files.
grep -r -l -a -P '\x00' /var/lib/docker/containers/ | xargs -I {} perl -pi -e 's/\x00//g' {}
Upvotes: 8
Reputation: 1446
I resolve this with docker compose by simply down it and up again
docker compose down
docker compose up -d
Upvotes: 56
Reputation: 2493
a workaroud may be clear the broken log file.
// the log still can be read (by cat or vim), just docker can't handle it
docker inspect --format='{{.LogPath}}' YOUR_CONTAINER
:> THE_LOG_PATH
https://stackoverflow.com/a/42510314/4896468
Upvotes: 15
Reputation: 1831
For windows you need delete json file with 0x00
bytes
located in %USERPROFILE%\.docker\contexts
folder and it's subdirs.
Upvotes: -1
Reputation: 61
Using windows Docker Desktop
Troubleshoot -> Reset to factory defaults
This fixed the issue for me.
Upvotes: 3
Reputation: 59
Looks like your events.log file got corrupted. Try deleting following file
"/var/run/docker/libcontainerd/containerd/events.log"
restart the docker through init.d
Upvotes: 5