I’m using docker-compose. My docker-compose.yml file looks like this:
web:
image: python:2.7
restart: always
build: .
depends_on:
- db
command: /bin/bash /code/start_maxlabs.sh
ports:
# - "85:80"
- "8001:8000"
- "8002:8005"
expose:
- "8000"
links:
- db:mysql
volumes:
- .:/code
- /usr/src/app
- /usr/src/app/static
- /usr/share/nginx/html
external_links:
- wordpress_web_1:localhost
I have a DockerFile like this:
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD environment.yml /code/
ADD requirements.txt /code/
ADD start_maxlabs.sh /code/
RUN chmod +x /code/start_maxlabs.sh
RUN apt-get update
RUN apt-get install -y python-pip python-dev build-essential
RUN apt-get install -y libmysqlclient-dev gunicorn
RUN apt-get install -y libcairo2-dev
RUN apt-get install -y libjpeg62-turbo-dev
RUN apt-get install -y libpango1.0-dev
RUN apt-get install -y libgif-dev
RUN apt-get install -y build-essential
RUN apt-get install -y g++
RUN apt-get install -y python-imaging
RUN pip install -U pip
RUN pip install mysql-python
RUN pip install gunicorn
RUN pip install -r requirements.txt
ADD . /code/
ADD maxlabs /code/
ADD webapp /code/
After I build, I have this coming from the container:
/usr/local/bin/gunicorn: No such file or directory
Clearly, I’ve told it to install. During the build process I can see that it successfully installed:
Installing collected packages: beautifulsoup4, html5lib, bleach, boto, bz2file, chardet, static3, dj-static, Django, django-bootstrap3, django-contrib-comments, sqlparse, django-debug-toolbar, django-frontend, django-frontend-skeleton, filebrowser-safe, oauth, flickr-api, future, numpy, scipy, gensim, geopy, grappelli-safe, gunicorn, requests, Pillow, oauthlib, requests-oauthlib, pytz, tzlocal, Mezzanine, nltk, python-dateutil, pandas, PasteDeploy, python-Levenshtein, scikit-learn, smart-open, Unidecode, var-dump
Found existing installation: gunicorn 19.7.0 (cool seems like it installed at some point then)
Also when I login to the container, the install script works fine. However, there seems to be multiple images available.
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> a09d3eff40f7 34 seconds ago 1.36 GB
python 2.7 ca388cdb5ac1 12 days ago 676 MB
The one with none:none seems to have my code and all the packages I told it to install. However, I think from the compose file, the command to run the code “command: /code/start_maxlabs.sh” (which contains the reference to run gunicorn), is trying to be run on the container running on “ca388cdb5ac1”, which I don’t completely understand? The thing that baffles me is that this exact setup works fine in production but not on my local machine. The deal with my production machine, is that it looks totally different when I type docker images
and docker ps
. I see only a single image : container combination for my Python app.
ubuntu@ip-xxx.xxx.xxx.xxx:~/deploy$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
40878483163e nginx:latest "nginx -g 'daemon off" 8 weeks ago Up 5 weeks 0.0.0.0:80->80/tcp, 443/tcp, 0.0.0.0:8080->80/tcp ng01
17fb36d7f6ea django "/bin/bash /code/star" 8 weeks ago Up 5 weeks 0.0.0.0:8001->8000/tcp, 0.0.0.0:8002->8005/tcp maxlabs
1984101b64ea mysql "docker-entrypoint.sh" 8 weeks ago Exited (1) 5 weeks ago 3306/tcp
Why does my localhost docker setup create so many containers? So confused