我正在尝试使用以下方法连接到我的IAM服务器:
curl -i -X POST -H“Content-type:application / json” http://localhost:9089/account/list -d'{“jwt”:“jwt_token ...”}'
并且这样做我得到如下错误:
卷曲:(7)无法连接到localhost端口9089:拒绝连接
任何建议都将不胜感激!
编辑:
> npm info it worked if it ends with ok npm info using npm@5.3.0 npm
> info using node@v8.5.0 npm info lifecycle iam@1.0.2~prestart:
> iam@1.0.2 npm info lifecycle iam@1.0.2~start: iam@1.0.2
>
> > iam@1.0.2 start /usr/src/app
> > node server.js
>
> HTTP listening on port 9089 HTTPS listening on port 9449
root@Ubuntu1604-001:/home/src/IAM# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
blandry/2 latest f127789f2de7 4 days ago 544MB
blandry/3 latest f127789f2de7 4 days ago 544MB
root@Ubuntu1604-001:/home/src/IAM# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cc28d00d1667 blandry "npm start" 33 minutes ago Up 33 minutes 0.0.0.0:32768->9089/tcp objective_mclean
Dockerfile:
FROM node:8.5.0-wheezy
RUN apt-get update
WORKDIR /usr/src/app
ENV ldap_port 389
ENV http_port 9089
ENV ladp_ip 10.119.226.149
ENV URL 10.119.226.149
ENV authentication eyJhbGciOiJIUz...
COPY package.json package-lock.json /usr/src/app/
COPY . .
EXPOSE 9089
CMD ["npm", "start"]
答案 0 :(得分:2)
尝试以下
curl -i -X POST -H "Content-type: application/json" http://localhost: 32768/account/list -d '{"jwt": "jwt_token..."}'
你的码头ps显示
root@Ubuntu1604-001:/home/src/IAM# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cc28d00d1667 blandry "npm start" 33 minutes ago Up 33 minutes 0.0.0.0:32768->9089/tcp objective_mclean
这意味着您没有将9089
映射到9089
。为此,请确保以
docker run -p 9089:9089 <image>
答案 1 :(得分:0)
如果您尝试在docker中进行此卷曲,则不需要http前缀。
我昨天遇到了同样的问题,当我尝试发送时,我成功了
curl name_of_container:port/path/to/the/method
。
答案 2 :(得分:0)
您已将32768主机端口映射到9089端口的docker。
root@Ubuntu1604-001:/home/src/IAM# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cc28d00d1667 blandry "npm start" 33 minutes ago Up 33 minutes 0.0.0.0:32768->9089/tcp objective_mclean
使用32768端口而不是9089端口。
curl -i -X POST -H&#34;内容类型:application / json&#34; http://localhost:32768/account/list -d&#39; {&#34; jwt&#34;:&#34; jwt_token ...&#34;}&#39;