Home > Software engineering >  Docker Max retries exceeded with url: /assets
Docker Max retries exceeded with url: /assets

Time:02-03

I'm a bit new to docker and I'm messing around with it. I currently have a server being ran on port 5000 in another container. This server is being ran with express and uses JavaScript. I'm trying to send requests to that server with python. I tried using both localhost:5000 and 127.0.0.1:5000 but neither of these seems to work. What can I do? I noticed if I run the python code without docker it works perfectly fine.

Python Docker File:

FROM ubuntu:latest

RUN apt update
RUN apt install python3 -y 
RUN apt-get install -y python3-pip

WORKDIR /usr/app/src
COPY . .

RUN pip install discum
RUN pip install python-dotenv

EXPOSE 5000
CMD ["python3", "./src/index.py"]

JavaScript Docker File:

FROM node:latest

WORKDIR /usr/src/app

COPY package.json ./
RUN npm install

COPY . .
CMD ["npm", "start"]

CodePudding user response:

You could create a network between the to containers using --net look at this answer How to get Docker containers to talk to each other while running on my local host?

Another way, and my preferred way, is to use docker-compose and create networks between your containers.

CodePudding user response:

Use Service Name and Port is always the best. So if you have a docker file like the below you could use the URL http://client:5000

version: 3.8
  services:
     client:
        image: blah
        ports:
          - 5000:5000
  • Related