S. Dior
S. Dior

Reputation: 463

Docker - port forwarding

I'm need help, can not connect to the container all day. I used this address: 127.0.0.1:80 and see: http://joxi.ru/Vm6oegWtxoQVK2. When enter this command 'docker ps' I see it:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
42941a9e0dda        docker_web          "python manage.py ru…"   45 seconds ago      Up 4 seconds        127.0.0.1:8000->80/tcp   docker_web_1

Docker-compose:

version: '3'

services:
  web:
    build:
    context: .
    dockerfile: /django.testsite/Dockerfile
  ports:
    - "127.0.0.1:8000:80"

Docerfile

FROM python:3

RUN easy_install pip
RUN pip install django==1.9.12
RUN pip install requests

ADD . /.
WORKDIR /django.testsite

CMD ["python", "manage.py", "runserver", "127.0.0.1:80"]

How solve?

Upvotes: 0

Views: 11311

Answers (1)

Chris Foster
Chris Foster

Reputation: 2649

In your docker-compose.yml file, you specify "127.0.0.1:8000:80" as the port mapping. This means that you are mapping port 8000 on your local ip, 127.0.0.1, to port 80 on the internal container.

Docker also reinforces this in the docker ps call, where it tells you that the container has a port mapping with 127.0.0.1:8000->80/tcp.

If you visit 127.0.0.1:80, there is nothing hosted on that port. You need to visit 127.0.0.1:8000 instead.

Upvotes: 4

Related Questions