Create a web2py docker image and access it through a browser

I am trying to create a web2py docker image 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 creating an image using the above Dockerfile

 docker build -t sandilya28/web2py . 

Then, creating the container using the image above

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

Host IP address

 192.168.59.103 

which can be found using boot2docker ip

After creating the image, I run web2py sever with

 python web2py/web2py.py 

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

How to access the web2py GUI from a browser.

+5
source share
1 answer

Creating a docker that starts the development web server will leave you with a very slow solution, as the web server will be single-threaded and will also serve all static files. It was meant for development.

Since you are not using https, it will also disable the web2py administration interface: it is only available through http if you access it from localhost.

As the saying goes, you can run your solution and run web2py with:

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

All parameters are important, since web2py needs to start the server without asking any questions, and it needs to bind to the external address of the network interface.

If you want to use a ready-made docker for production to run web2py, you will need additional components in your docker; nginx, uwsgi and supervisord would do it a lot faster and give you options to enable https. Note. For large projects, you probably need a python binding for MySql or PostgreSQL and a separate docker database.

An example of production without fantasy DB support can be found here:

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

It can be installed from a docker hub using:

 docker pulll acidjunk/web2py 

Be sure to read the instructions as you will need a web2py application; which will be installed in the container. If you just want to start the web2py server to play with an example or a welcome application, you can use:

 docker pull thehipbot/web2py 

Start with:

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

Then launch the browser for

https://192.168.59.103

0
source

All Articles