在docker容器中运行Django应用程序时获取502 Bad Gateway?

时间:2017-04-25 12:00:49

标签: django docker

以下步骤是我在Docker容器中运行我的应用程序。

#!/bin/bash
#activate virtual env
echo Activate vitualenv.
source /home/my_env/bin/activate

#restart nginx
echo Restarting Nginx
service nginx restart

# Start Gunicorn processes
echo Starting Gunicorn.
gunicorn OPC.wsgi:application --bind=0.0.0.0:8000 --daemon

我的启动脚本:

CREATE OR REPLACE FUNCTION process_fillDerivedFromGenby() RETURNS TRIGGER AS $fillDerivedFromgenby$
  DECLARE
    prog     varchar(255);
    curent   varchar(255);
  BEGIN

    SELECT u.iduseentity , g.idCreatedEntity into prog,curent
    FROM entity e
    JOIN used u ON e.identity=u.iduseentity
    JOIN activity a ON a.idactivity=u.idusedactivity
    JOIN generatedby g ON g.idcreatoractivity=a.idactivity
    WHERE g.idCreatedEntity =NEW.idCreatedEntity;

    --raise notice 'curent: "%" prog by "%"', curent, prog;

    INSERT INTO DERIVEDFROM VALUES(prog,curent);
    return new;
  END;

$fillDerivedFromgenby$ LANGUAGE plpgsql;
CREATE TRIGGER fillDerivedFromgenby AFTER INSERT ON GENERATEDBY
    FOR EACH ROW EXECUTE PROCEDURE process_fillDerivedFromGenby();

此设置在本地计算机上正常工作,但在docker中无法正常工作。

1 个答案:

答案 0 :(得分:0)

当我的nginx服务器在端口80响应

时,需要更改端口没有应用程序可访问
docker run -i -t -d -p 80:80 c4ba9ec8e613 /bin/bash
docker attach c4ba9ec8e613