Dmitry Bakanov created AIRFLOW-6236:
---------------------------------------
Summary: Unable to get logs from DockerOperator
Key: AIRFLOW-6236
URL: https://issues.apache.org/jira/browse/AIRFLOW-6236
Project: Apache Airflow
Issue Type: Bug
Components: operators
Affects Versions: 1.10.6, 1.10.5
Reporter: Dmitry Bakanov
Hi, I tried to migrate from Airflow 1.10.2 to Airflow 1.10.5 or 1.10.6. I
don't see output from my docker container in Airflow task logs.
I found that there was a fix:
[https://github.com/apache/airflow/commit/305c9e6db01a2e78c39c03ca71941acf3e88a13d]
I tried to inherit from DockerOperator and replaced
{code:java}
line = ''
for line in self.cli.attach(container=self.container['Id'],
stdout=True,
stderr=True,
stream=True):
line = line.strip()
if hasattr(line, 'decode'):
line = line.decode('utf-8')
self.log.info(line){code}
with
{code:java}
line = ''
for line in self.cli.logs(container=self.container['Id'], stream=True):
line = line.strip()
if hasattr(line, 'decode'):
line = line.decode('utf-8')
self.log.info(line)
{code}
The latest code snippet is from 1.10.2. After this manipulation I can see log
output again.
I observed, that the first code snippet doesn't raise any exception, but it
doesn't do anything, probably because 'attach' returns an empty array or
something like that.
I should say that I didn't try any complex scenario. My DockerOperator command
is just 'env'. I use docker api lib 'docker==3.7.3' and explicitly specify
docker API version as '1.37'. I use docker desktop for Mac Version 2.0.0.3
(31259)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)