question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

containers.run() hangs without output when image is missing (+/- invalid mount)

See original GitHub issue

Hi all,

First of all thanks for the continued work on this SDK – it’s been very useful for making quick work of some local e2e tests. I ran into this problem while a colleague was trying to run some tests that “ran on my machine”.

Issue

TL;DR - If you do not have the image you want to run pulled (for example minio/minio), and you have a configuration error (such as an invalid mount specified), the containers.run command will hang (due to one or more silent failures) – the container will never be pulled, the program will not continue past or error, and the underlying mount problem won’t cause an error either – to the end user it just looks like a hang with no output.

The first progress we were able to make was installing the minio/minio image with the docker CLI directly – this got rid of the missing image problem (maybe docker-py doesn’t fetch missing automatically, I thought this was docker run standard behavior), and exposed an invalid mount configuration issue. The mount configuration issue has to do with how OSX temp directories are created (once the error was visible it was easy to fix):

E       docker.errors.APIError: 502 Server Error: Bad Gateway ("b'Mounts denied: \r\nThe path /var/folders/wj/x6b1l_7s1yg977rxrrjpsc8h0000gn/T/project-9dk0ewdx\r\nis not shared from OS X and is not known to Docker.\r\nYou can configure shared paths from Docker -> Preferences... -> File Sharing.\r\nSee https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.\r\n.'")

this issue is due to namespacing on OSX, and the interaction with python’s tempfile functionality:

import tempfile

# Create tmp local directory for minio to use                                                                                                                                                                                                                                 
d = tempfile.mkdtemp(prefix="e2e-minio") # /var/folders/wj/x6b1l_7s1yg977rxrrjpsc8h0000gn/T/project-minio9dk0ewdx

The fact that this folder can’t be used by the spawned docker container is more of a gotcha more than a bug (maybe both of these issues are), so I’m not sure exactly what should be done (maybe it’s just adding more documentation).

The main issue is the missing container appearing as a hang (which might have been exacerbated by the invalid mount issue), with no output (error or otherwise) returned to the user.

Reproduction

Steps:

  1. Install docker (native) 18.02 (latest as of 02/16) on OSX
  2. Create a python project that uses tmpfile.mkdtemp
  3. Create a client with docker.from_env()
  4. Run docker_client.containers.run w/ a mounted directory that is the temp directory

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
DanielSCrouchcommented, Jun 29, 2020

Thanks for this, new to Docker and this took way to much time to figure out. Seems a simple update to the docs is in order https://docs.docker.com/engine/api/sdk/examples/

import docker
client = docker.from_env()
print client.containers.run("alpine", ["echo", "hello", "world"])

to

import docker
client = docker.from_env()
print client.containers.run("alpine:latest", ["echo", "hello", "world"])

Edit: Further to the above, pulling a remote image hangs even with the above. Logging in first works

r = client.login(username="xxxx", password="yyyy")
1reaction
shinebayar-gcommented, Oct 3, 2020

Thanks to the docs. I pulled entire library of ubuntu image.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot volume errors - Docker Documentation
This topic discusses errors which may occur when you use Docker volumes or bind mounts. Error: Unable to remove filesystem. Some container-based utilities, ......
Read more >
Python app does not print anything when running detached in ...
Finally I found a solution to see Python output when running daemonized in Docker, ... You can see logs on detached image if...
Read more >
10 things to avoid in docker containers | Red Hat Developer
First: Containers are immutable - The OS, library versions, configurations, folders, and application are all wrapped inside the container. You ...
Read more >
Find out Why Your Docker Container Keeps Crashing
Your Docker container is exiting without a useful error message? Here are a few ways to find out what's happening.
Read more >
Troubleshoot common issues - Azure Container Instances
To resolve this issue, delete the container instance and retry your deployment. Ensure that the image exists in the registry, and that you've ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found