Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create a web2py docker image and access it through browser

Tags:

docker

web2py

I'm trying to build a docker image of web2py on top of ubuntu. Given the docker file

    #######################
    # Web2py installation #
    #######################

    # Set the base image for this installation
    FROM ubuntu

    # File Author/ Mainteainer
    MAINTAINER sandilya28

    #Update the repository sources list
    RUN apt-get update --assume-yes

    ########### BEGIN INSTALLATION #############

    ## Install Git first
    RUN apt-get install git-core --assume-yes && \ 
    cd /home/ && \ 
    git clone --recursive https://github.com/web2py/web2py.git

    ## Install Python

   RUN sudo apt-get install python --assume-yes

   ########## END INSTALLATION ################

   # Expose the default port
   EXPOSE 8000

   WORKDIR /home/

By building an image using the above Dockerfile

docker build -t sandilya28/web2py .

Then by building a container using the above image

docker run --name my_web2py -p 8000:8000 -it sandilya28/web2py bash

The ip address of the host is

192.168.59.103

which can be found by using boot2docker ip

After creating the image I'm starting the web2py sever using

python web2py/web2py.py

and I'm trying to access the web2py GUI from 192.168.59.103:8000 but it is showing the page is not available.

How to access the GUI of web2py from the browser.

like image 731
Sandilya Miduthuri Avatar asked May 25 '15 07:05

Sandilya Miduthuri


1 Answers

Creating a docker that runs the development webserver will leave you with a very slow solution as the webserver is single threaded and will also serve all static files. It's meant for development.

As you don't use https it will also disable the web2py admin interface: that's only available over http if you access it from localhost.

That being said, you can get your solution up and running by starting web2py with:

python web2py.py --nogui -a admin -i 0.0.0.0

All options are important as web2py needs to start the server without asking any questions and it needs to bind to external netwerk interface address.

When you want to use a production ready docker to run web2py you would need some additional components in your docker; nginx, uwsgi and supervisord would make it a lot faster and give you the options to enable https. Note: for bigger projects you would probably need python binding for MySql or PostgreSQL and a separate docker with the database.

An production example, without fancy DB support, can be found here:

https://github.com/acidjunk/docker-web2py

It can be installed from the docker hub with:

docker pulll acidjunk/web2py

Make sure to read the instructions as you'll need a web2py app; that will be mounted in the container. If you just want to start a web2py server to fiddle around with the example or welcome app you can use:

docker pull thehipbot/web2py

Start it with:

docker run -p 443:443 -p 80:80 thehipbot/web2py

Then fire up a browser to

https://192.168.59.103

like image 186
acidjunk Avatar answered Oct 18 '22 10:10

acidjunk