创build一个web2pydocker图像并通过浏览器访问它

我正在尝试在Ubuntu上build立一个web2py的docker镜像。 给定docker文件

####################### # 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/ 

通过使用上面的Dockerfile构build一个图像

 docker build -t sandilya28/web2py . 

然后通过使用上面的图像build立一个容器

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

主机的IP地址是

 192.168.59.103 

这可以通过使用boot2docker ipfind

创build图像后,我开始使用web2py服务器

 python web2py/web2py.py 

我试图从192.168.59.103:8000访问web2py GUI,但它显示页面不可用。

如何从浏览器访问web2py的GUI。

创build一个运行开发web服务器的docker将会给你一个非常慢的解决scheme,因为web服务器是单线程的,并且也会提供所有的静态文件。 这是为了发展。

由于您不使用https,因此也会禁用web2pypipe理界面:只有通过http访问本地主机时才能使用该界面。

这就是说,你可以通过启动web2py来启动和运行你的解决scheme:

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

所有选项都非常重要,因为web2py需要启动服务器而不会提出任何问题,而且需要绑定到外部networking接口地址。

当你想使用生产准备好的docker来运行web2py时,你需要在docker中增加一些组件。 nginx,uwsgi和supervisord会使它快很多,并为您提供启用https的选项。 注意:对于更大的项目,您可能需要python绑定MySql或PostgreSQL和单独的数据库泊坞窗。

一个生产例子,没有花哨的DB支持,可以在这里find:

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

它可以从docker集线器安装:

 docker pulll acidjunk/web2py 

请务必阅读说明,因为您需要一个web2py应用程序; 将被安装在容器中。 如果你只是想启动一个web2py服务器来摆弄这个例子或者欢迎程序,你可以使用:

 docker pull thehipbot/web2py 

从以下开始:

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

然后启动浏览器

https://192.168.59.103