0

I'm working on Django website, and while deploying it on Linux Ubuntu server i've faced some problems:

I made a dockerfile (and docker compose file), pushed it into Docker Hub, pulled it from my Linux server, launched this docker image via docker-compose, and then i only see logs of PostgreSQL (i don't even see any errors from Django side). I also try to reach this website from other computers, but it gives me "ERR_CONNECTION_TIMED_OUT" error. I'll appreciate any help!

(outtask is the name of the project) here's my Dockerfile code:

FROM python:3.10

ENV PYTHONUNBUFFERED 0

WORKDIR /code

COPY ./requirements.txt .

RUN pip install --upgrade pip && pip install --upgrade setuptools wheel
RUN pip install -r requirements.txt

COPY . .


EXPOSE 8000

here's my docker-compose code:

version: '3.9'
services:
  db:
    image: postgres
    volumes:
      - type: volume
        source: pg_data
        target: /var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    ports:
      - 5432:5432

  django:
    image: django-docker:0.0.1
    build: .
    command: sh -c "gunicorn --bind 0.0.0.0:8000 outtask.wsgi:application" 
#    sh -c "python3 -u outtask/manage.py runserver 0.0.0.0:8000"
    volumes:
      - type: bind
        source: .
        target: /outtask
      - type: volume
        source: static_data
        target: /outtask/static
    ports:
      - "8000:8000"
    environment:
    - DJANGO_SETTINGS_MODULE=outtask.settings

    depends_on:
      - db

volumes:
  pg_data:
  static_data:

Code of settings.py you can look up with this link (don't look at strange placement of dockerfiles, i've already fixed it on production): https://github.com/sh1nkey/outtask_v1/blob/main/outtask/outtask/settings.py

Edit: Here are logs of Docker-compose file on linux server:


version: '3'
services:
  web:
    image: sh1nkey/outtask1:latest
    ports:
      - "80:80"

There are logs while launching the project on linux server:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A,               or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2023-05-19 12:30:29.719 UTC [47] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc               (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-05-19 12:30:29.723 UTC [47] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-05-19 12:30:29.735 UTC [50] LOG:  database system was shut down at 2023-05-19 12:30:29 UTC
2023-05-19 12:30:29.740 UTC [47] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

2023-05-19 12:30:29.825 UTC [47] LOG:  received fast shutdown request
waiting for server to shut down....2023-05-19 12:30:29.827 UTC [47] LOG:  aborting any active transactions
2023-05-19 12:30:29.829 UTC [47] LOG:  background worker "logical replication launcher" (PID 53) exited with exit code 1
2023-05-19 12:30:29.830 UTC [48] LOG:  shutting down
2023-05-19 12:30:29.833 UTC [48] LOG:  checkpoint starting: shutdown immediate
2023-05-19 12:30:29.849 UTC [48] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.005 s, sync=0.003 s, total=0.020 s; sync files=2, longest=0.002 s, average=0.002 s; distance=0 kB, estimate=0 kB
2023-05-19 12:30:29.853 UTC [47] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2023-05-19 12:30:29.946 UTC [1] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 202101              10, 64-bit
2023-05-19 12:30:29.947 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port5432
2023-05-19 12:30:29.947 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-05-19 12:30:29.954 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-05-19 12:30:29.960 UTC [61] LOG:  database system was shut down at 2023-05-19 12:30:29 UTC
2023-05-19 12:30:29.966 UTC [1] LOG:  database system is ready to accept connections

-tried to launch it with command docker run -t -p 8080:80 sh1nkey/outtask1 -tried to change commands in docker-compose file

schinken
  • 1
  • 3
  • Are you sure the logs coming from this docker-compose file, I can't see a service called `web`. – Marco May 19 '23 at 09:31
  • You seem to have included a link to an image file in place of the logs; can you [edit] the question to include the logs in plain text? Does setting `PYTHONUNBUFFERED` to `1` ([not `0`](/a/59812588)) make any difference? – David Maze May 19 '23 at 10:43
  • @Marco: my bad, i've forgot to add code of docker-compose file on my linux server. I added it now – schinken May 19 '23 at 12:29
  • @DavidMaze thank you. i found out that the problem was because of wrong tagging with Dockehub: I DID NOT HAVE ANUTHING BESIDES MY DB IMAGE ON MY DOCKER HUB. – schinken May 19 '23 at 13:29

1 Answers1

0

Case closed. It was because of mistakes in using Docker Hub. I didn't know you can't put two images in Docker Hub repo, but I tried and failed

schinken
  • 1
  • 3