pserve not working inside docker container

49
December 10, 2019, at 11:20 PM

I am trying to develop pyramid application with using docker-container.I build a docker images with below docker file.

FROM ubuntu
RUN  apt-get -y update
RUN  apt-get -y install python3.6 python3.6-dev libssl-dev wget git python3-pip libmysqlclient-dev
WORKDIR /application
COPY . /application
RUN pip3 install -e .
EXPOSE 6543

This is my docker-compose file

version: '3'
services:
  webserver:
    ports:
      - 6543:6543
    build:
      context: .
      dockerfile: Dockerfile-development
    volumes:
      - .:/application
    command: pserve development.ini --reload

The docker image is created successfully. But when i run the docker-compose up and browse the url localhost:6543 it is showing The site can't be reached now. But when i run it locally with pserve development.ini it is working fine. I tried to connect to the docker interactively and run the command pserve develpment.ini, It is showing as

Starting server in PID 18.
Serving on http://localhost:6543

But when i browse the url from chrome it is not working.

Answer 1

You need to listen in all network interfaces. In your development.ini file, use:

listen = *:6543

You should get a log which says:

Serving on http://0.0.0.0:6543

Then try to access it from your host machine using localhost:6543.

READ ALSO
Download multiple files in Django without creating zip

Download multiple files in Django without creating zip

Is there a way to download multiple files in Django without creating zipfile on single click/requestFor downloading single file I am using the following code in views

15
Unable to write policy document in aws cdk using python

Unable to write policy document in aws cdk using python

Hi I am working on AWS CDKI am trying to create policy

43
How to use regex to extract a number from a URL using pandas

How to use regex to extract a number from a URL using pandas

I'm at a stage to extract the page number from a URL which I got from web scrapingThis page number I will use to make a loop

23