docker/docker-py

Error initiating docker client. Python hang after trying to find config file

hubertokf opened this issue · 4 comments

python hangs on this messages:

2019-04-12 14:13:52,323 [MainThread  ] [DEBUG]  Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
2019-04-12 14:13:52,323 [MainThread  ] [DEBUG]  No config file found
2019-04-12 14:13:52,323 [MainThread  ] [DEBUG]  Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
2019-04-12 14:13:52,323 [MainThread  ] [DEBUG]  No config file found

this is the code:

client = docker.from_env()
    volumes={
    work_dir+'input/album': {'bind': '/code/images', 'mode': 'rw'},
    work_dir+'output/odm_orthophoto': {'bind': '/code/odm_orthophoto', 'mode': 'rw'},
    work_dir+'output/odm_meshing': {'bind': '/code/odm_meshing', 'mode': 'rw'},
    work_dir+'output/odm_georeferencing': {'bind': '/code/odm_georeferencing', 'mode': 'rw'},
    work_dir+'output/odm_texturing': {'bind': '/code/odm_texturing', 'mode': 'rw'},
    work_dir+'output/opensfm': {'bind': '/code/opensfm', 'mode': 'rw'},
    work_dir+'output/pmvs': {'bind': '/code/pmvs', 'mode': 'rw'},
    work_dir+'output/odm_dem': {'bind': '/code/odm_dem', 'mode': 'rw'}
    }

    try:
        container = client.containers.run('opendronemap/opendronemap', command="--skip-3dmodel --time --dtm --dsm", volumes=volumes, auto_remove=True, tty=True, stdin_open=True, detach=False)
        
    except docker.errors.ContainerError:
        logging.error('ERROR: Erro na execução do container docker')
        error = {
            'code': 6,
            'message': 'Erro na execução do container docker'
        }
        
  
        runCommand("sh /home/vantum/vantum-scripts/shutdown.sh")

        sys.exit()
    except docker.errors.ImageNotFound:
        logging.error('ERROR: Imagem docker não encontrada')
        error = {
            'code': 7,
            'message': 'Imagem docker não encontrada'
        }
        
       
      
        runCommand("sh /home/vantum/vantum-scripts/shutdown.sh")

        sys.exit()
    except docker.errors.APIError:
        logging.error('ERROR: Erro na API docker')
        error = {
            'code': 8,
            'message': 'Erro na API docker'
        }
        
       
        runCommand("sh /home/vantum/vantum-scripts/shutdown.sh")

        sys.exit()
    except:
        error = {
            'code': 8,
            'message': 'Erro inesperado no docker: '+sys.exc_info()[0]
        }
        logging.error('ERROR: Erro inesperado no docker: '+error)
        
        logging.info('Saving memory logs')

       
        runCommand("sh /home/vantum/vantum-scripts/shutdown.sh")

        sys.exit()
        raise

Sometimes it gives me except on error code 8, but no error given.

by the way is there a way to store logs on a file?

Have also seen this.
Same issue no config file found

The missing config file is definitely not an error: it's really just a debugging statement that you don't have any config.

Can you run the container with docker CLI and verify it's functional?

Yes, it is functional @TomasTomecek. I have tested, after it hangs, I can run any container using docker command.

I am facing the same issue as well. The CLI is running ok, but not from the docker-py