I m new to docker.
I ve downloaded a docker image at docker pull lambci/lambda:build-python3.8
which is a aws image to run lambda functions.
I ve a Dockerfile that is : Dockerfile:
FROM lambci/lambda:build-python3.8
WORKDIR /var/task
EXPOSE 8000
RUN echo 'export PS1="\[\e[36m\]zappashell>\[\e[m\] "' >> /root/.bashrc
CMD ["bash"]
I've run
docker build -t zappa-docker-image .
docker run -ti -p 8000:8000 -e AWS_PROFILE=zappa -v "$(pwd):/var/task" -v ~/.aws/:/root/.aws --rm zappa-docker-image
When I run django inside my docker image (python manage.py runserver), i get the following error:
OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address
Is the server running on that host and accepting TCP/IP connections?
I guess it's related to postgresql in my django settings :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dbtest',
'USER': 'postgres',
'PASSWORD': '1234',
'HOST': 'localhost',
'PORT': '5432',
}
}
When I run the django server outside docker i dont get the error ... How can i solve this error in docker?