unittest print nie działa w docker compose

0

Hejka,

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal
$ /usr/bin/docker --version
Docker version 24.0.6, build ed223bc

Dockerfile:

RUN python -m unittest scan_3306_port.py
import unittest
import nmap

class TestPortScan(unittest.TestCase):
    def test_scan(self):
        print("Scanning local network for hosts...")
        nm = nmap.PortScanner()
        nm.scan(hosts='172.20.0.0/16', arguments='-sn -n')
        hosts = [host for host in nm.all_hosts() if nm[host].state() == 'up']
        print(f"Found {len(hosts)} hosts on the local network: {', '.join(hosts)}")
        self.assertGreater(len(hosts), 0, 'No hosts found on the local network')

        print("Scanning each host for open 3306 ports...")
        for host in hosts:
            nm.scan(hosts=host, arguments='-p 3306')
            if 'tcp' in nm[host].all_protocols() and 3306 in nm[host]['tcp']:
                print(f"Host {host} has open 3306 port")
                return  # Return success code immediately after finding one host with open 3306 port
            else:
                print(f"Host {host} does not have open 3306 port")

        print("No hosts with open 3306 port found.")
        self.fail("No hosts with open 3306 port found.")  # Fail the test if no hosts with open 3306 port are found

if __name__ == '__main__':
    print("Running port scan test...")
    unittest.main(exit=False)  # Prevent unittest from exiting after running the test
$ /usr/bin/docker compose up --force-recreate

I oto tyle co widać na ekranie co dotyczy tego unittest'u:

=> [server stage-0 32/36] RUN python -m unittest scan_3306_port.py                                                                         1981.6s

Co to ma być, gdzie jest reszta informacji? Od czego to zależy?...

1 użytkowników online, w tym zalogowanych: 0, gości: 1