Azure IoT Edge module log location - azure-iot-edge

Where are the logs exposed by the iotedge logs <container> command stored?
Where would that be generally on Linux?

Simply do a docker inspect <Container ID> and under LogPath you will get the current location of the container. E.g. for EdgeHub on my machine: LogPath:
/var/lib/docker/containers/f8ecdf408f94f5627ac635223ce89dd9b1433705f342d548e09863cedf0fc950/f8ecdf408f94f5627ac635223ce89dd9b1433705f342d548e09863cedf0fc950-json.log

By default, they are stored in /var/lib/docker/containers//-json.log.

Related

How to docker container logs to a local file?

I need to look up into docker logs for some days ago and checking by docker service logs SERVICE | grep WHAT_I_NEED takes forever so I want to download the container logs from docker swarm and check those locally. I found that the container logs in Swarm can be found by:
docker inspect --format='{{.LogPath}}' $INSTANCE_ID
but I can't find a way to download the log from the location.
Doing: docker cp CONTAINER_ID:/var/lib/docker/containers/ABC/ABC-json.log ./ tells me that the path is not present. I understand that this path is in Swarm but then how to get the log from the container itself? Or is there another way to copy this file directly to a local file?
Try running this one from your terminal:
docker logs your_container_name 2> file.log
This will redirect the container logs to the local file file.log

Location of docker logs in Ubuntu Linux Mint

I am able to find my application logs using docker logs --follow containerId
But which is the physical location of these logs?
I used this link, But nothing is useful: Where is the Docker daemon log?
Thanks,
Harry
Those aren't the docker daemon logs. Those are normally stored in JSON files unless otherwise specified by the driver you select for logging.
They're normally stored in :
/var/lib/docker/containers/<container id>/<container id>-json.log
But you can verify with
docker inspect <container> | grep LogPath
Docker native command to find log location for any container docker inspect --format={{.LogPath}} <ContainerName>
ContainerId can also be used if needed to

Docker log (driver json-file) location for Docker for windows

I want to locate a container's log location.
I use Docker Desktop for Windows
I know that on linux they are at /var/lib/docker/containers/
But where is it. Is it hidden away somewhere in an inaccessible VM?
Windows 10 + WSL 2 (Ubuntu 20.04), Docker version 20.10.2, build 2291f61
Logging Driver
docker info --format '{{.LoggingDriver}}'
'json-file'
Docker Inspect LogPath
docker inspect --format='{{.LogPath}}' <Some_Container_id>
'/var/lib/docker/containers/bb69ae7df957c5f8c8b6d63372aa9cf9b94fa6ef0e44ccecbccb6d190baadb51/bb69ae7df957c5f8c8b6d63372aa9cf9b94fa6ef0e44ccecbccb6d190baadb51-json.log'
Docker Artifacts are stored in following location
DOCKER_ARTIFACTS == \\wsl$\docker-desktop-data\version-pack-data\community\docker
Location of container logs
DOCKER_ARTIFACTS\containers\[Your_container_ID]\[Your_container_ID]-json.log
Here is an example:
On windows you can find the containers logs inside:
C:\ProgramData\docker\containers\[Your_container_ID]\[Your_container_ID]-json.log
For windows , the container storage is the Hyper V's virtual Hard disk.You would have to connect to that hard disk to get the container logs.
See this lonk for more details :https://forums.docker.com/t/where-are-images-stored/9794/7

Access hosts zfs from docker container

Is there a way to access the hosts zfs snapshots from within the docker?
I'm trying to get some custom backup, using zfs snapshots with send/receive, running on a cluster of docker based servers. To stick to the current setup, I'd like the backup service to run in a docker container as well. I'm having a hard time figuring out if there's any way to access the hosts file system, on an administrative level, from within a docker container.
I basically need a way to run zfs list, zfs snap and zfs send from within the container. My gut tells me "no", but maybe there's a clever way by some mount options and privilege wizardry
I use rancherOS 1.3.0 with zfs on /mnt
i start container with:
privileged: true
pid: host
volumes:
- /mnt:/mnt:shared
with this confis i can clone snaphots
for me it worked with:
docker container in privileged mode
zfs device mapped into the container (--device /dev/zfs)
zfsutils-linux installed in the container
Znapzend (a backup utility using ZFS snapshots) covers this in their github page: https://github.com/oetiker/znapzend#running-in-container. I'm using this to automate backups on my NAS to a separate offsite backup NAS.
Here's the relevant info from the link:
---SNIP---
znapzend is also available as docker container image. It needs to be a privileged container depending on permissions.
docker run -d --name znapzend --device /dev/zfs --privileged \
oetiker/znapzend:master
To configure znapzend, run in interactive mode:
docker exec -it znapzend /bin/sh
$ znapzendzetup create ...
# After exiting, restart znapzend container or send the HUP signal to
# reload config
By default, znapzend in container runs with --logto /dev/stdout. If you wish to add different arguments, overwrite them at the end of the command:
docker run --name znapzend --device /dev/zfs --privileged \
oetiker/znapzend:master znapzend --logto /dev/stdout --runonce --debug
Be sure not to daemonize znapzend in the container, as that exits the container immediately.
---SNIP---
Unfortunately, there is no way to do that. We've had the same problem ourselves, and the way we worked around it was by creating a container-less service which the containers can issue commands to, and the container-less service could then issue ZFS commands on their behalf and return the results. It's not a perfect solution, but (at least for us) it was better than nothing.

Is there a way to start a docker container in bluemix and see the command line output?

I am having problems to run my docker container on bluemix. The container runs without any problem in my local machine but crashes in bluemix. Is there a way to start a container in bluemix via the "ice" command and see the console output in the same way as I can see it without the "-d" command in my local docker installation?
You can see the console output of IBM Containers with the following command line:
ice logs <container id>
Depending on the tool you use:
ice logs <container id>
cf ic logs <container id>
docker logs <container id>

Resources