Docker Community Forums

Share and learn in the Docker community.

Dockerizing Web2py, issue with interactive/daemon mode


(Jf002) #1

Hi,

I’m a beginner with Docker, and I’m trying to dockerize Web2Py, a web-framework written in Python.

Here is the Dockerfile:

FROM debian:jessie
    
MAINTAINER me
    
# Update apt repositories and install Python
RUN apt-get update && \
    apt-get install -y python && \
    apt-get clean
   
WORKDIR /opt/web2py
    
# Copy Web2py
ADD web2py_src/ /opt/web2py/
ADD certificates/* /opt/web2py/
   
# Expose port 8000
EXPOSE 8000
    
# Run web2py
ENTRYPOINT ["./web2py.py", "-i 0.0.0.0", "-a 'pwd'", "-c /opt/web2py/server.crt", "-k /opt/web2py/server.key"]

The image is built with the command

docker build -t my_web2py .

and the current directory contains the directories ‘web2py_src’ (which contains all the source files of web2py) and ‘certificates’ (which contains server.crt and server.key’).

This Dockerfile works fine if I remove the arguments -c and -k.
In this case, Web2Py starts in HTTP mode, and it works as expected.
However, I would like to start it in HTTPS mode, with -c and -k.

If I run the container in daemon mode :

docker run -d -p 8000:8000 my_web2py

Web2py complains that it cannot load the certificate file.

However, if I start bash instead of web2py:

docker run --name web2py_1 -it  -p 8000:8000 --entrypoint=/bin/bash  my_web2py -i

the certificate files are correctly loaded and Web2py works in HTTPS.

So, it seems that the container do not behave the same when it runs the ENTRYPOINT command at startup and when the command is ran manually by BASH… And I don’t understand why…

Any ideas?

Thanks!


(Ranjandas) #2

Hi,

Can you modify the entrypoint as shown below and try?

ENTRYPOINT ["./web2py.py", "-i", "0.0.0.0", "-a", "'pwd'", "-c", "/opt/web2py/server.crt", "-k ", "/opt/web2py/server.key"]

Regards


(Jf002) #3

Thank you @ranjandas, that fixes my issues. The arguments were badly formatted in the ENTRYPOINT. Now, my container and web2py runs as expected!