I have 2 microservices that I'm dockerizing via docker-compose. Once my node service pings my python service, I get a connection refused.
I can ping both services independently via Postman and everything looks fine. It seems the container-to-container networking is what I'm having issues with. The node server is pinging a request via Axios
like so:
const res = await axios.get('bot:9000/test')
and the server code on the Python side looks like:
@app.route('/test', methods=['GET'])
async def tester():
return jsonify(data='hi'), 200
Compose File
version: '3'
services:
bot:
build:
dockerfile: Dockerfile.dev
context: ./app-bot
volumes:
- /app/node_modules
- ./app-bot:/app
environment:
- TELEGRAM_API_KEY=xxxx
- BOT_PORT=4040
channel-scraper:
restart: always
image: quart-app
environment:
- QUART_APP=api
build:
context: ./app-channelscrape/server
dockerfile: Dockerfile
ports:
- "9000:9000"
env_file:
- .env
Node Docker File
FROM node:alpine
WORKDIR "/app"
COPY ./package.json ./
RUN npm install
RUN npm install -g nodemon
COPY . .
CMD ["npm", "run", "start"]
Flask Docker File
FROM python:3.7-alpine
RUN adduser -D quart
WORKDIR /home/quart
COPY ./requirements.txt ./
RUN rm -rf /var/cache/apk/*
RUN pip install --no-cache-dir -r requirements.txt --upgrade && \
chown -R quart:quart ./
COPY ./ /home/quart/
USER quart
CMD ["quart", "run", "-h", "0.0.0.0", "-p", "9000"]
bot
as a host name, but from the bot service itself; do you mean to callhttp://channel-scraper:9000
to reach the other service? – David Maze Jan 17 at 11:57