Docker image builds on laptop, not on Digital Ocean - my understanding of Docker is shattered
Question: I have a non-trivial `Docker` environment for a Python app I'm building (see
below for full `Dockerfile`). On my MacBook (with `Docker version 1.10.3,
build 20f81dd`) I am able to build the `Docker` image, run the container and
the app works fine.

I now want to test the app on Digital Ocean. I have only ever used Docker on
my laptop up to this point. I created a droplet using the `Ubuntu Docker
1.10.3 on 14.04` image. I SSH'd in, cloned my git repo, executed the `docker
build` command, but I got an error during the build (see bottom for full stack
trace).

    
    
    Exception: Cython-generated file 'pandas/index.c' not found.
               Cython is required to compile pandas from a development branch.
               Please install Cython or download a release package of pandas. 
    

This is a valid exception, but my questions is: **_Why would the
same`Dockerfile` and `docker build` command successfully build on one machine,
but raise an exception on another?_** My understanding of Docker was that it
prevented this sort of thing from happening by building the environment from
scratch using just the Dockerfile...I just can't wrap my head around what is
causing this exception on one machine and not the other.

* * *

**`Dockerfile`**

    
    
    FROM python:2.7
    
    ENV HOME /root
    
    # Install dependencies
    RUN apt-get update \
        && apt-get upgrade -y
    RUN apt-get install -y apt-utils
    RUN apt-get install -y gcc
    RUN apt-get install -y build-essential
    RUN apt-get install -y zlib1g-dev
    RUN apt-get install -y wget
    RUN apt-get install -y unzip
    RUN apt-get install -y cmake
    RUN apt-get install -y gfortran 
    RUN apt-get install -y libatlas-base-dev 
    RUN apt-get install -y python-pip 
    RUN apt-get install -y python-dev
    RUN apt-get install -y subversion
    RUN apt-get install -y supervisor
    RUN apt-get install -y nginx
    RUN apt-get clean
    
    # Install Python packages
    RUN pip install --upgrade pip
    RUN pip install numpy
    RUN pip install pandas
    RUN pip install bottleneck
    RUN pip install boto3
    RUN pip install scipy
    RUN pip install Flask
    RUN pip install uwsgi
    
    # Build OpenCV and dependencies
    RUN cd && wget https://github.com/Itseez/opencv/archive/3.1.0.zip \
        && git clone https://github.com/Itseez/opencv_contrib.git \
            && unzip 3.1.0.zip \
            && cd opencv-3.1.0 && mkdir build && cd build \
            && cmake -D CMAKE_BUILD_TYPE=RELEASE \
                 -D CMAKE_INSTALL_PREFIX=/usr/local \
                 -D INSTALL_C_EXAMPLES=OFF \
                 -D INSTALL_PYTHON_EXAMPLES=ON \
                 -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
                 -D BUILD_EXAMPLES=ON .. \
        && make -j2 && make install \
            && cd && rm -rf opencv-3.1.0 && rm 3.1.0.zip
    
    # Build HDF5
    RUN cd ; wget https://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.16.tar.gz
    RUN cd ; tar zxf hdf5-1.8.16.tar.gz
    RUN cd ; mv hdf5-1.8.16 hdf5-setup
    RUN cd ; cd hdf5-setup ; ./configure --prefix=/usr/local/
    RUN cd ; cd hdf5-setup ; make && make install
    
    # Cleanup
    RUN cd ; rm -rf hdf5-setup
    RUN apt-get -yq autoremove
    RUN apt-get clean
    RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
    
    # Install Python packages with dependencies on HDF5
    RUN pip install tables
    RUN pip install h5py
    RUN pip install -U scikit-image
    
    RUN rm -fr /root/.cache
    
    # Update environment and working directories
    ENV PYTHONUNBUFFERED 1
    WORKDIR /app
    ADD . /app
    RUN mv config ../config
    
    # Setup config
    RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
    RUN rm /etc/nginx/sites-enabled/default
    
    RUN ln -s /config/nginx.conf /etc/nginx/sites-enabled/
    RUN ln -s /config/supervisor.conf /etc/supervisor/conf.d/
    
    EXPOSE 80
    CMD ["python", "app.py"]
    

**`Stack Trace`**

    
    
    creating build/lib.linux-x86_64-2.7/pandas/tseries/tests/data
        copying pandas/tseries/tests/data/series_daterange0.pickle -> build/lib.linux-x86_64-2.7/pandas/tseries/tests/data
        copying pandas/tseries/tests/data/frame.pickle -> build/lib.linux-x86_64-2.7/pandas/tseries/tests/data
        copying pandas/tseries/tests/data/dateoffset_0_15_2.pickle -> build/lib.linux-x86_64-2.7/pandas/tseries/tests/data
        copying pandas/tseries/tests/data/daterange_073.pickle -> build/lib.linux-x86_64-2.7/pandas/tseries/tests/data
        copying pandas/tseries/tests/data/series.pickle -> build/lib.linux-x86_64-2.7/pandas/tseries/tests/data
        copying pandas/tseries/tests/data/cday-0.14.1.pickle -> build/lib.linux-x86_64-2.7/pandas/tseries/tests/data
        UPDATING build/lib.linux-x86_64-2.7/pandas/_version.py
        set build/lib.linux-x86_64-2.7/pandas/_version.py to '0.18.0'
        running build_ext
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-build-OD55P2/pandas/setup.py", line 604, in <module>
            **setuptools_kwargs)
          File "/usr/local/lib/python2.7/distutils/core.py", line 151, in setup
            dist.run_commands()
          File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
            self.run_command(cmd)
          File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
            cmd_obj.run()
          File "/usr/local/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run
            return orig.install.run(self)
          File "/usr/local/lib/python2.7/distutils/command/install.py", line 563, in run
            self.run_command('build')
          File "/usr/local/lib/python2.7/distutils/cmd.py", line 326, in run_command
            self.distribution.run_command(command)
          File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
            cmd_obj.run()
          File "/usr/local/lib/python2.7/distutils/command/build.py", line 127, in run
            self.run_command(cmd_name)
          File "/usr/local/lib/python2.7/distutils/cmd.py", line 326, in run_command
            self.distribution.run_command(command)
          File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
            cmd_obj.run()
          File "/usr/local/lib/python2.7/distutils/command/build_ext.py", line 339, in run
            self.build_extensions()
          File "/tmp/pip-build-OD55P2/pandas/setup.py", line 316, in build_extensions
            self.check_cython_extensions(self.extensions)
          File "/tmp/pip-build-OD55P2/pandas/setup.py", line 313, in check_cython_extensions
            """ % src)
        Exception: Cython-generated file 'pandas/index.c' not found.
                        Cython is required to compile pandas from a development branch.
                        Please install Cython or download a release package of pandas.
    
    
        ----------------------------------------
    Command "/usr/local/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-OD55P2/pandas/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-JQaDVa-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-OD55P2/pandas/
    The command '/bin/sh -c pip install pandas' returned a non-zero code: 1
    


Answer: I don't know about your specific problem, but to answer your general question:

> Why would the same Dockerfile and docker build command successfully build on
> one machine, but raise an exception on another?

It's likely that the machines are using different `python:2.7` images. Many
images (especially official ones) are rebuilt often, and [the `python` tags
page](https://hub.docker.com/r/library/python/tags/) says `2.7` was last built
6 days ago. If you just created the DigitalOcean instance, it would be using
the latest `python:2.7`, but if you pulled that image more than six days ago,
you would be using an out of date image. If you run `docker pull python:2.7`
on your local machine and try to rebuild, you should get the same error that
you're seeing on DigitalOcean.

An alternative, yet related, possible cause could be [build
caching](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-
practices/#build-cache): If one of the many packages your Dockerfile installs
has changed recently, but you haven't edited that line of the Dockerfile or
any line above it recently, the Docker instance on your local machine would
continue using the old version when building. You can turn off the use of the
build cache on your local machine by passing the `--no-cache` option to
`docker build`.

Other possible reasons for a Docker build to succeed on one machine and fail
on another include using different versions of Docker or using an HTTP proxy
when downloading packages on one machine and a different proxy (or no proxy)
on the other.

