【发布时间】:2021-04-02 01:49:12
【问题描述】:
我正在尝试构建一个 docker 容器并使用 jenkins 对同一个构建的容器运行我的集成测试。
我目前遇到的问题是我可以构建和运行容器,当我尝试对 http 端点进行 curl 时,我收到连接拒绝。所以我相信这与我的詹金斯奴隶配置有关。我已将 jenkins 用户添加到 wheel docker jenkins 组,当我运行记录为 jenkins 的 curl 命令时,它可以工作。但是当我从詹金斯运行它时,我收到了连接拒绝。
JenkinsFile
sh "docker build -t my-service ."
sh "docker rm -f my-service || true"
sh "docker run -d -p 9091:5000 -p 1433:1433 --name=my-service my-service"
sh "docker ps"
sh "curl -v http://172.16.32.20:9091/api/products/"
詹金斯输出
+ curl -v http://172.16.32.20:9091/api/products/baggingoptions
* About to connect() to 172.16.32.20 port 9091 (#0)
* Trying 172.16.32.20...
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:--
0* Connection refused
* Failed connect to 172.16.32.20:9091; Connection refused
* Closing connection 0
curl: (7) Failed connect to 172.16.32.20:9091; Connection refused
从站信息:
Static hostname: **************************
Icon name: computer-vm
Chassis: vm
Machine ID: 009cdec7fded4740be96692dfee788c0
Boot ID: fe492def29c047bf910c213911fda980
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-514.26.2.el7.x86_64
Architecture: x86-64
【问题讨论】:
-
为什么要映射两个端口?您的服务在两个不同的端口(5000 和 1433)上运行?
-
我的应用程序需要这两个端口
标签: curl docker jenkins centos