moby: Docker hangs badly when doing a python install
I have the following dockerfile:
# Base python 3.4 build, inspired by
# https://github.com/crosbymichael/python-docker/blob/master/Dockerfile
# Originally from https://github.com/micktwomey/docker-python3.4/blob/master/Dockerfile
FROM ubuntu:14.04
MAINTAINER Wayne Werner <waynejwerner@gmail.com>
RUN echo "deb http://ppa.launchpad.net/fkrull/deadsnakes/ubuntu trusty main" > /etc/apt/sources.list.d/deadsnakes.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DB82666C
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
python3.4 \
&& apt-get autoremove \
&& apt-get clean
ADD https://github.com/pypa/pip/raw/645180e2714b4ffcf40363a608239e089c9dafab/contrib/get-pip.py /root/get-pip.py
RUN python3.4 /root/get-pip.py
RUN pip3.4 install -U "setuptools"
RUN pip3.4 install -U "pip"
ADD dist/scheduler-0.1.0.tar.gz /scheduler
RUN python3.4 /scheduler/scheduler-0.1.0/setup.py install
#ENTRYPOINT ["/usr/bin/python3.4"]
Scheduler consists of the following files:
scheduler/Dockerfile
scheduler/setup.py
scheduler/README
scheduler/scheduler/__init__.py
scheduler/scheduler/server.py
scheduler/scripts/scheduler
all of the files are empty except setup.py and scripts/scheduler
setup.py
import os
from setuptools import setup
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = "scheduler",
version = "0.1.0",
author = "Wayne Werner",
author_email = "waynejwerner@gmail.com",
description = ("Breaking docker"),
url = "",
packages=['scheduler'],
scripts=['scripts/scheduler'],
long_description=read('README'),
install_requires=['Flask',
'flask-login',
'flask-wtf',
'sqlalchemy',
'click',
],
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Applications",
],
)
scripts/scheduler:
#!/usr/bin/env python
import click
import sys
#from scheduler import server
@click.command()
@click.option('--name', default='World', help="Name to greet")
def main(name):
print("Hey {}!".format(name), sys.executable)
if __name__ == '__main__':
main()
When I run $ docker build --tag="wayne/scheduler:latest" .
then it gets as far as this:
---> Running in 64df88c57386
running install
Checking .pth file support in /usr/local/lib/python3.4/dist-packages/
/usr/bin/python3.4 -E -c pass
TEST PASSED: /usr/local/lib/python3.4/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
creating scheduler.egg-info
writing top-level names to scheduler.egg-info/top_level.txt
writing dependency_links to scheduler.egg-info/dependency_links.txt
writing requirements to scheduler.egg-info/requires.txt
writing scheduler.egg-info/PKG-INFO
writing manifest file 'scheduler.egg-info/SOURCES.txt'
And then it hangs - but it’s a very very busy hang. This is the output of ps aux | grep scheduler
on my host box:
root 5419 0.1 0.0 4452 752 ? Ss 11:19 0:00 /bin/sh -c python3.4 /scheduler/scheduler-0.1.0/setup.py install
root 5436 96.0 0.6 72396 30296 ? R 11:19 0:15 python3.4 /scheduler/scheduler-0.1.0/setup.py install
The only thing I can do is kill -9
either of these processes.
Now, if I skip the RUN
step and then boot into the box with
$ docker run --rm -it wayne/scheduler /bin/bash
then I can do a python3.4 setup.py install
just fine.
My host box is Arch Linux.
Let me know if you have any questions!
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 15 (1 by maintainers)
Haha, ok, the issue is that you’re calling setup.py from
/
and distutils does a listdir(‘.’) from the calling directory, so I assume it’s walking the entire filesystem. So I guess, don’t do that.https://github.com/python/cpython/blob/master/Lib/distutils/filelist.py#L245
I put
pip install -r requirements.txt
in Dockerfile anddocker build
hangs at that line. I restarted docker and then everything is fine@jseabold well, that makes sense. And kind of the worst, lol.
I guess the sensible thing to do would be to change the run line to this:
I would ask on stackoverlow then. This is a docker issue tracker.