Docker Community Forums

Share and learn in the Docker community.

Debugging non-working container

docker

(Larrymartell59) #1

I have a container and when I start it it exits after a few seconds with no output. How can I debug this to see where the issue is?d


(John Harris) #2

Are you able to post your Dockerfile & the command you are using to run the container?

Also what does the output of $ docker logs <container> show?


(Larrymartell59) #3

docker logs gives no output. Here is the Dockerfile:

FROM debian:jessie
MAINTAINER Larry Martell larry.martell@elucidbio.com

ENV HOME /opt/django/CAPgraph/

RUN (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip)
RUN (easy_install pip &&
pip install uwsgi)

ADD . $HOME
RUN pip install -r $HOME/requirements.txt
RUN chmod 777 /opt/django
RUN chmod 777 $HOME

ADD deploy/stardog/stardog-4.0.zip $HOME/stardog-4.0.zip
RUN cd $HOME && unzip stardog-4.0.zip && rm stardog-4.0.zip && mv stardog-4.0 stardog
ENV STARDOG_HOME $HOME/cap_data/knowledge
ADD deploy/stardog/stardog-license-key.bin $HOME/deploy/stardog/stardog-license-key.bin
ADD deploy/stardog/init $HOME/deploy/stardog/init

COPY deploy/util /usr/local/bin
RUN chmod a+x /usr/local/bin/reset_CAPgraph /usr/local/bin/start_CAPgraph /usr/local/bin/stop_CAPgraph

RUN (echo “daemon off;” >> /etc/nginx/nginx.conf &&
rm /etc/nginx/sites-enabled/default &&
ln -s /opt/django/CAPgraph/django.conf /etc/nginx/sites-enabled/ &&
ln -s /opt/django/CAPgraph/supervisord.conf /etc/supervisor/conf.d/)

ADD mysql /var/lib/mysql

VOLUME ["/opt/django/CAPgraph"]
VOLUME ["/var/lib/mysql"]
EXPOSE 80 8006
ADD crontab /etc/cron.d/backupMySQL
RUN chmod 0644 /etc/cron.d/backupMySQL
RUN touch /var/log/cron.log

CMD ["/opt/django/CAPgraph/run.sh"]

The run.sh has:

chown -R mysql:mysql /var/lib/mysql
mysql_install_db --user=mysql --ldata=/var/lib/mysql/
/usr/bin/mysqld_safe &
sleep 5
mysql -u root -e "CREATE DATABASE IF NOT EXISTS elucid"
mysql -u root -e “SET PASSWORD FOR ‘root’@‘localhost’ = PASSWORD(‘xxxxxx’)”

chmod 0777 /opt/django/CAPgraph/scripts/backupMySQL.py
set -e

sed -i “s#module=website.wsgi:application#module=wsgi:application#g” /opt/django/CAPgraph/uwsgi.ini
sed -i ‘/session required pam_loginuid.so/c#session required pam_loginuid.so’ /etc/pam.d/cron

python /opt/django/CAPgraph/manage.py collectstatic --noinput
rm -f /opt/django/CAPgraph/app.sock
rm -f /opt/django/CAPgraph/cap_data/knowledge/system.lock
/opt/django/CAPgraph/stardog/bin/stardog-admin server start

exec /usr/bin/supervisord

I run it like this:

docker run -d -v /projects/elucid/CAPgraph:/opt/django/CAPgraph -v /projects/elucid/CAPgraph/mysql:/var/lib/mysql -v /etc/localtime:/etc/localtime -v /projects/cap_data:/opt/django/CAPgraph/cap_data -p 8004:80 -p 8006:8006 -p 45820:5820 elucidbio/capgraph:local

When I first ran it I got this error:

/opt/django/CAPgraph/run.sh: line 19: /opt/django/CAPgraph/stardog/bin/stardog-admin: No such file or directory

So I wanted to start the container with a shell and look around. So I commented out the run script in the Dockerfile and made a new image. And when I run that I get nothing and the container exits.


(David Maze) #4

You don’t need to comment anything out; anything you pass in the docker run command overrides the CMD in the Dockerfile. It’s extremely common to

docker run --rm -it mycontainername bash

to try to do exactly this sort of debugging.


(Larrymartell59) #5

Thanks very much. This is what I needed to know. I was able to find the issues and get it working.