I had a question regarding docker-compose files and having an image use another image through a requests.post
call? I am having trouble either connecting the two images together and/or accessing the images.
Here is what my docker-compose.yml looks like:
version: "3.7"
services:
cerberus:
image: "ctpelok77/ibmresearchaiplanningsolver"
ports:
- "4501:4501"
my-external-planner:
build: .
ports:
- "8000:8000"
I then use the following commands:
docker-compose up -d
docker run -it external-planner_my-external-planner
Inside the my-external-command
, I use the following line response = requests.post('http://cerberus:4501/planners/satisficing/seq-sat-cerberus', headers=headers, data=body_str)
; however, this gives me a
requests.exceptions.ConnectionError: HTTPConnectionPool(host='cerberus', port=4501): Max retries exceeded with
url: /planners/satisficing/seq-sat-cerberus (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f90eeb04510>: Failed to establish a new connection: [Errno -2] Name or service not known',))
I was wondering if I am not correctly connecting my images in the docker-compose or if I am incorrectly trying to access the images in my image?
I was able to amend this issue by giving the services specific names and assigning them a shared network in the docker-compose.yml
file:
version: "3.7"
services:
my-ibm-planner:
image: "ctpelok77/ibmresearchaiplanningsolver"
ports:
- "4501:4501"
container_name: "ibm-container"
networks:
- network-planner
tty: true
my-external-planner:
image: "docker.sift.net/tbessho/external-planner"
ports:
- "8000:8000"
networks:
- network-planner
container_name: "ext-plan"
tty: true
networks:
network-planner:
name: network-planner
along with changing the python script to use the following line:
response = requests.post('http://ibm-container:4501/planners/satisficing/seq-sat-cerberus')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.