I have a python function to read a specific docker container log.
First I try to get the container id as below
def test_1(): logging.info("Test debug logs") ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('10.18.18.10', username='usr1', password='pwd1') ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('sudo docker ps -aqf "name=container1"') container_id = ssh_stdout.read().decode("utf-8").replace('\n', '') ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(f'sudo docker logs -f {container_id} --since 4m') container_logs = ssh_stdout.read() ssh.close() I am getting the container_id fine. But I am not getting the container_logs. The execution keeps going when I try to retrieve the logs.
P.S. Anyway technically I can read the docker logs by container name too. But I need to know why I was not able to read the output the second time.