small fix - use dockerDNS
1
# run.sh
docker rm $(docker stop $(docker ps -a -q --filter ancestor=w2pnginx
--format="{{.ID}}"))
docker rm $(docker stop $(docker ps -a -q --filter ancestor=w2pguni
--format="{{.ID}}"))
docker network rm w2pnet
docker network create --subnet=172.25.0.0/16 w2pnet
docker build -t w2pguni -f guniDoc .
docker run -d --net w2pnet -p 9005:9005 --name w2pname --ip 172.25.0.22
w2pguni
# docker exec -it w2pname bash
sleep 2
ping -c1 -n 172.25.0.22
docker run --net w2pnet busybox ping -c1 -n w2pname
echo "------------------------------------------------------------------"
curl -I 172.25.0.22:9005
docker build -t w2pnginx -f nginxDoc .
docker run -d --net w2pnet --name nginxname --ip 172.25.0.23 w2pnginx
# docker exec -it nginxname bash
sleep 2
ping -c1 -n 172.25.0.23
docker run --net w2pnet busybox ping -c1 -n nginxname
echo "------------------------------------------------------------------"
curl -I 172.25.0.23
docker ps
docker network ls
docker network inspect w2pnet
2
#w2p.conf
upstream gunicorn {
server w2pname:9005 fail_timeout=0;
}
server {
listen nginxname:80 default_server;
#listen 172.25.0.23:80 default_server;
location / {
try_files $uri @proxy_to_gunicorn;
}
location @proxy_to_gunicorn {
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_set_header Host $host;
proxy_pass http://gunicorn;
}
}
On Friday, January 5, 2018 at 5:45:04 AM UTC+3, 黄祥 wrote:
>
> just wondering why gunicorn dockerfile with web2py/anyserver.py is not
> work when use with python:2.7 image
> e.g.
> *step i took*
> cat <<EOF > Dockerfile
> FROM python:2.7
> RUN apt update && \
> apt install -y unzip wget gunicorn
> RUN groupadd -r web2py && \
> useradd -m -r -g web2py web2py
> USER web2py
> RUN cd /home/web2py/ && \
> wget -c http://web2py.com/examples/static/web2py_src.zip && \
> unzip -o web2py_src.zip && \
> rm -rf /home/web2py/web2py/applications/examples && \
> chmod 755 -R /home/web2py/web2py
> EXPOSE 80
> CMD cd ~ && python /home/web2py/web2py/anyserver.py -s gunicorn -i 0.0.0.0
> -p 80
> EOF
> docker build .
> docker images
> docker run -p 80:80 imageid
>
> *result*
> starting gunicorn on 0.0.0.0:80...
> Traceback (most recent call last):
> File "/home/web2py/web2py/anyserver.py", line 365, in <module>
> main()
> File "/home/web2py/web2py/anyserver.py", line 362, in main
> options=options)
> File "/home/web2py/web2py/anyserver.py", line 314, in run
> getattr(Servers, servername)(application, (ip, int(port)),
> options=options)
> File "/home/web2py/web2py/anyserver.py", line 137, in gunicorn
> from gunicorn.app.base import Application
> ImportError: No module named gunicorn.app.base
>
> but it works well when using ubuntu latest image
> *e.g.*
> *step i took*
> cat <<EOF > Dockerfile
> FROM ubuntu:latest
> RUN apt update && \
> apt install -y python python-pip python-setuptools unzip vim wget
> gunicorn && \
> pip install --upgrade pip && \
> pip install virtualenv && \
> virtualenv /home/site && \
> rm -rf /home/site/web2py && \
> cd /home/site/ && \
> rm -f web2py_src.zip && \
> wget -c http://web2py.com/examples/static/web2py_src.zip && \
> unzip -o web2py_src.zip && \
> rm -rf /home/site/web2py/applications/examples && \
> chmod 755 -R /home/site/web2py
> EXPOSE 80
> CMD . /home/site/bin/activate && /usr/bin/python
> /home/site/web2py/anyserver.py -s gunicorn -i 0.0.0.0 -p 80
> EOF
> docker build .
> docker images
> docker run -p 80:80 imageid
>
> all tested in https://labs.play-with-docker.com
>
> thanks and best regards,
> stifan
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.