I'm running a Docker container with a Python application that writes logs to the stdout
with the Python standard logging
lib. The container is not hosted in any Google Cloud product but on my own machine.
I configured docker to use the gcplogs
driver as described on this guide and the official driver docs.
The docker container runs with no problems. However, no logs are being collected because I don't see anything on the Stackdriver logging viewer, other than some weird "ping" log entries that are produced on each execution of the docker container.
The python logger is configured via dictConfig
:
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
'stream': 'ext://sys.stdout'
},
The docker container is ran with this command:
docker run --env-file `pwd`/.env \
--label app=oncrm \
--log-driver=gcplogs \
--log-opt gcp-meta-name= host_name\
--log-opt gcp-project=cloud_project_id \
--log-opt labels=app \
--name oncrm \
--net host \
--rm \
-v `pwd`/data:/code/data \
-v `pwd`/logs:/code/logs \
docker_image sh update_subs.sh
The driver documentation doesn't really specify where are log being collected from but it does mention that the driver should also work outside the Google Cloud Platform/Products.
Environment:
- Python 3.6.4 (official DockerHub image for Alpine3.7)
- Docker-ce 18.03.0
- Ubuntu 17.10
- Stackdriver Premium tier