I am recently learning docker. I want to run elasticsearch using docker. It works fine when I only add code to run elastic search in docker file. But I am getting Connection error caused by: ConnectionError(Connection error caused by: NewConnectionError
when I update docker-compose.yml file to start server, postgresql db and elastic search.
Below is the code for dockerfile and docker-compose.yml file.
Dockerfile
FROM python:3.8-slim-buster ENV PYTHONUNBUFFERED=1 WORKDIR /code COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt COPY . /code/
docker-compose.yml
`version: ‘3’
services:
db:
image: postgres:13
volumes:
– postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: myproject
POSTGRES_USER: myprojectuser
POSTGRES_PASSWORD: password
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
– .:/code
ports:
– “8000:8000”
depends_on:
– db
– es
environment:
– DATABASE_URL=postgres://myprojectuser:password@db:5432/myproject
es:
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0
environment:
– discovery.type=single-node
ports:
– “9200:9200”
volumes:
– es_data:/usr/share/elasticsearch/data
volumes:
postgres_data:
es_data:
`
Can anyone help me to fix this error please?
I tried to run only elastic search container, it works fine. But when I update docker-compose.yml file to start django server, pg db and elastic search I am getting issue.
Sampurna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.