我是Docker
的新用户并设置docker
以使用Django
和gunicorn
nginx
申请
我的配置文件是
搬运工-compose.yml
version: '3'
services:
nginx:
image: nginx:latest
container_name: "myapp-nginx"
ports:
- "10080:80"
- "10443:43"
volumes:
- .:/app
- ./config/nginx:/etc/nginx/conf.d
- ./static_cdn:/static
depends_on:
- web
web:
build: .
container_name: "myapp-dev"
command: ./start.sh
volumes:
- .:/app
- ./static_cdn:/static
ports:
- "9010"
depends_on:
- db
expose:
- "9010"
db:
image: postgres
container_name: "myapp-db"
配置/ nginx的/ nginx.conf
upstream web {
ip_hash;
server web:9010;
}
server {
location /static {
autoindex on;
alias /static/;
}
location / {
proxy_pass http://web;
}
listen 9010;
server_name localhost;
}
start.sh
#!/usr/bin/env bash
# Start Gunicorn processes
echo --: Starting application build
echo --: Creating migration
python3 manage.py makemigrations
echo ------: makemigrations complete
echo --: Running migration
python3 manage.py migrate
echo ------: migrate complete
echo --: Running collectstatic
python3 manage.py collectstatic <<<yes
echo ------: collectstatic complete
echo --: Starting Gunicorn.
gunicorn koober.wsgi:application \
--bind 0.0.0.0:9010 \
--workers 3
使用
运行dockerdocker-compose up --build
成功运行,输出为
这里的gunicorn在0.0.0.0:9010
成功启动。但无法使用浏览器访问该应用程序。
我在浏览器中尝试了以下地址
答案 0 :(得分:1)
试试这个
linear = tf.layers.dense(z, 512 * 8 * 8)
linear = tf.contrib.layers.batch_norm(linear, is_training=is_training,decay=0.88)
conv = tf.reshape(linear, (-1, 128, 128, 1))
out = tf.layers.conv2d_transpose(conv, 64,kernel_size=4,strides=2, padding='SAME')
out = tf.layers.dropout(out, keep_prob)
out = tf.contrib.layers.batch_norm(out, is_training=is_training,decay=0.88)
out = tf.nn.leaky_relu(out)
out = tf.layers.conv2d_transpose(out, 128,kernel_size=4,strides=1, padding='SAME')
out = tf.layers.dropout(out, keep_prob)
out = tf.contrib.layers.batch_norm(out, is_training=is_training,decay=0.88)
out = tf.layers.conv2d_transpose(out, 3,kernel_size=4,strides=1, padding='SAME')
print( out.get_shape())
Nginx应该侦听 10080 端口,因为在您的撰写文件中,您已经暴露了端口80到10080端口。
然后尝试 http://localhost:10080 或 http://machine-ip-address:10080
这里是我写的博客,用于解释Docker + Nginx + Web应用程序如何协同工作。
源代码 https://github.com/RohanMohite/Docker-Nginx-PHP/blob/master/server_nginx/conf/server.conf