Docker Community Forums

Share and learn in the Docker community.

Python app presents different behavior running on docker with and without volume


(Rodrigozc) #1

Expected behavior

App running with volume configuration

Actual behavior

App crashes and doesn’t find some libs, but without volume runs perfectly.

Information

Docker Info

Containers: 35
    Running: 4
    Paused: 0
    Stopped: 31
Images: 38
Server Version: 1.11.2
Storage Driver: aufs
    Root Dir: /mnt/sda1/var/lib/docker/aufs
    Backing Filesystem: extfs
    Dirs: 146
    Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
    Volume: local
    Network: bridge null host
Kernel Version: 4.4.12-boot2docker
Operating System: Boot2Docker 1.11.2 (TCL 7.1); HEAD : a6645c3 - Wed Jun 1 22:59:51 UTC 2016
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.955 GiB
Name: default
ID: MRX3:YAS6:IPHW:CYEQ:DWUB:SYIR:VHJY:BC24:6FEJ:7LMW:FEQ2:QZBF
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug mode (client): false
Debug mode (server): true
    File Descriptors: 52
    Goroutines: 92
    System Time: 2016-07-25T21:25:22.050672486Z
    EventsListeners: 1
Username: rodrigozc
Registry:
Labels:
    provider=virtualbox

Dockerfile

FROM python:2-onbuild

MAINTAINER Rodrigo Zampieri Castilho rodrigo.zampieri@gmail.com

ENV PYTHONUNBUFFERED 1

RUN apt-get update
RUN apt-get install -y nodejs npm
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN npm install -g phantomjs-prebuilt coffee-script less rapydscript

RUN mkdir /app
WORKDIR /app
ADD requirements.txt /app/
RUN pip install -r requirements.txt
ADD . /app/

docker-compose.yml

version: '2’
services:
    db:
        image: postgres
    web:
        build: .
        command: python manage.py runserver 0.0.0.0:8000
        volumes:
            - .:/app
        ports:
            - “8000:8000”
        depends_on:
            - db

Git repository app

Rhombik/rhombik-object-repository

Fixed requirements.txt

amqp==1.4.9
anyjson==0.3.3
beautifulsoup4==4.3.1
billiard==3.3.0.23
celery==3.1.23
cffi==0.8.6
CoffeeScript==1.0.9
cryptography==1.4
cssselect==0.9.1
Django==1.7.5
django-appconf==0.6
django-crispy-forms==1.4.0
django-debug-toolbar==0.11
django-easy-maps==0.8.4
django-guardian==1.2.5
django-haystack==2.3.1
django-mptt==0.6.1
django-pipeline==1.4.6
django-pipeline-rapydscript==1.0.0
django-ratings==0.3.7
django-reversion==1.8.0
django-simple-captcha==0.4.0
django-static-precompiler==0.7
django-taggit==0.12.2
django-taggit-autosuggest==0.2
django-taggit-templatetags==0.2.5
django-templatetag-sugar==0.1
django-threadedcomments==0.9.0
enum34==1.1.6
futures==3.0.5
html2text==2016.5.29
html5lib==0.999
idna==2.1
ipaddress==1.0.16
jobtastic==0.2.2
kombu==3.0.35
lxml==3.3.6
Markdown==2.3.1
Pillow==2.4.0
psutil==4.3.0
psycopg2==2.6.2
pyasn1==0.1.9
pycallgraph==1.0.1
pycparser==2.10
pyelasticsearch==0.6
PyExecJS==1.0.4
pyOpenSSL==0.14
python-cloudfiles==1.7.10
pytz==2016.6.1
queuelib==1.2.2
requests==2.2.0
Scrapy==0.24.4
selenium==2.35.0
simplejson==3.3.0
six==1.9.0
South==0.8.2
sqlparse==0.1.10
Twisted==14.0.0
virtualenv==15.0.2
w3lib==1.10.0
Whoosh==2.6.0
zope.interface==4.1.1

Steps to reproduce error:

  1. git clone https://github.com/Rhombik/rhombik-object-repository
  2. cd rhombik-object-repository
  3. copy Dockerfile and docker-compose.yml to rhombik-object-repository directory
  4. update requirements.txt from repository with above content
  5. docker-compose run web python manage.py migrate

Error:

Rodrigos-MacBook-Pro:rhombik_object_repository rodrigocastilho$ docker-compose run web python manage.py migrate
Traceback (most recent call last):
File “manage.py”, line 22, in
execute_from_command_line(sys.argv)
File “/usr/local/lib/python2.7/site-packages/django/core/management/init.py”, line 385, in execute_from_command_line
utility.execute()
File “/usr/local/lib/python2.7/site-packages/django/core/management/init.py”, line 345, in execute
settings.INSTALLED_APPS
File “/usr/local/lib/python2.7/site-packages/django/conf/init.py”, line 46, in getattr
self._setup(name)
File “/usr/local/lib/python2.7/site-packages/django/conf/init.py”, line 42, in _setup
self._wrapped = Settings(settings_module)
File “/usr/local/lib/python2.7/site-packages/django/conf/init.py”, line 98, in init
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings ‘Settings.settings’ (Is it on sys.path? Is there an import error in the settings file?): No module named defaultSettings

If you comment volumes entry on docker-compose.yml, the app migration runs without problems.

Success:

Rodrigos-MacBook-Pro:rhombik_object_repository rodrigocastilho$ docker-compose run web python manage.py migrate
System check identified some issues:

Operations to perform:
Synchronize unmigrated apps: importer, threadedComments, pipeline, mptt, gitHooks, avatarBot, guardian, scraper, pipeline_rapydscript, captcha, testcases, searchsettings, organization, haystack, bootstrapTheme, djangoratings, crispy_forms, userProfile
Apply all migrations: sessions, admin, filemanager, sites, kombu_transport_django, project, contenttypes, auth, taggit
Synchronizing apps without migrations:
Creating tables…
Installing custom SQL…
Installing indexes…
Running migrations:
No migrations to apply.