AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-367023

user977828's questions

Martin Hope
user977828
Asked: 2021-05-18 04:21:51 +0800 CST

Docker-compose 数据库的 IP 地址

  • 2

我找到了一个 Django 项目,但未能通过以下方式在 Docker 容器中运行:

  1. git clone https://github.com/hotdogee/django-blast.git

  2. $ cat requirements.txt在此文件中,必须更新以下依赖项:

    • 海带==3.0.30
    • psycopg2==2.8.6

我有以下 Dockerfile:

FROM python:2
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

因为docker-compose.yml我使用:

version: "3"

services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

docker-compose 使用哪个 IP 地址,因为我必须更改以下硬编码地址:

$ grep -ir "127.0.0.1" 
i5k/settings_prod.py:    'HOST': '127.0.0.1',
i5k/settings.py:    'HOST': '127.0.0.1',
i5k/settings.py:        'LOCATION': '127.0.0.1:11211',
Binary file i5k/settings.pyc matches
example/blastdb/AGLA_new_ids.faa.phd:13312790801051
grep: data/db: Permission denied
blast/static/blast/components/code-mirror/codemirror-4.0/mode/nginx/index.html:    fastcgi_pass   127.0.0.1:9000;
blast/static/blast/components/code-mirror/codemirror-4.0/mode/nginx/index.html:    fastcgi_pass 127.0.0.1:9000;
axes/tests.py:        reset(ip='127.0.0.1')
axes/decorators.py:            ip_address = '127.0.0.1'

先感谢您

django python postgresql docker-compose
  • 1 个回答
  • 1819 Views
Martin Hope
user977828
Asked: 2021-05-17 15:41:54 +0800 CST

django.db.utils.OperationalError:无法连接到服务器:连接被拒绝

  • -1

我找到了一个 Django 项目,但未能通过以下方式在 Docker 容器中运行:

  1. git clone https://github.com/hotdogee/django-blast.git

  2. $ cat requirements.txt在此文件中,必须更新以下依赖项:

    • 海带==3.0.30
    • psycopg2==2.8.6

我有以下 Dockerfile:

FROM python:2
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

因为docker-compose.yml我使用:

version: "3"

services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

接下来,我遇到了这个错误:

$ docker-compose build
...

web_1  | System check identified no issues (0 silenced).
web_1  | Unhandled exception in thread started by <function wrapper at 0x7f265ed26850>
web_1  | Traceback (most recent call last):
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 223, in wrapper
web_1  |     fn(*args, **kwargs)
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
web_1  |     self.check_migrations()
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 164, in check_migrations
web_1  |     executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 19, in __init__
web_1  |     self.loader = MigrationLoader(self.connection)
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in __init__
web_1  |     self.build_graph()
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 180, in build_graph
web_1  |     self.applied_migrations = recorder.applied_migrations()
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
web_1  |     self.ensure_schema()
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 49, in ensure_schema
web_1  |     if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 162, in cursor
web_1  |     cursor = self.make_debug_cursor(self._cursor())
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 135, in _cursor
web_1  |     self.ensure_connection()
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
web_1  |     self.connect()
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
web_1  |     six.reraise(dj_exc_type, dj_exc_value, traceback)
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
web_1  |     self.connect()
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 119, in connect
web_1  |     self.connection = self.get_new_connection(conn_params)
web_1  |   File "/usr/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 172, in get_new_connection
web_1  |     connection = Database.connect(**conn_params)
web_1  |   File "/usr/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 127, in connect
web_1  |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
web_1  | django.db.utils.OperationalError: could not connect to server: Connection refused
web_1  |    Is the server running on host "127.0.0.1" and accepting
web_1  |    TCP/IP connections on port 5432?

我错过了什么?

先感谢您

django python postgresql docker docker-compose
  • 2 个回答
  • 6103 Views
Martin Hope
user977828
Asked: 2021-05-15 15:14:15 +0800 CST

错误:无法从“11.7”确定 PostgreSQL 版本

  • 3

我找到了一个 Django 项目,但未能通过以下方式在 Docker 容器中运行:

  1. git clone https://github.com/hotdogee/django-blast.git

我有以下 Dockerfile:

FROM python:2
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

因为docker-compose.yml我使用:

version: "3"

services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

接下来,我遇到了这个错误:

$ docker-compose build
...
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-Gq_JSR/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-Gq_JSR/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info
         cwd: /tmp/pip-install-Gq_JSR/psycopg2/
    Complete output (7 lines):
    running egg_info
    creating /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info
    writing /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to /tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file '/tmp/pip-install-Gq_JSR/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    Error: could not determine PostgreSQL version from '11.7'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 20.0.2; however, version 20.3.4 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1

我错过了什么?

先感谢您

django python postgresql docker-compose
  • 1 个回答
  • 1767 Views
Martin Hope
user977828
Asked: 2021-05-14 22:59:14 +0800 CST

Django 导致无法与 Docker 连接

  • 0

我找到了一个 Django 项目,但未能通过以下方式在 Docker 容器中运行:

  1. git clone https://github.com/hotdogee/django-blast.git

  2. $ cat requirements.txt

    #psycopg2==2.6.0 # 如果使用 postgreSQL 作为数据库后端

我有以下 Dockerfile:

FROM python:2.7

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        postgresql-client \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .

EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

接下来,我跑了:

$ docker run --name some-django-app -p 8000:8000 -d my-django-app
4202d7b2b47603e32dc800d3fbedbfaf4363f8cafe45684242aa3bb2b0eba257

最后,我输入http://localhost:8000/并得到了Firefox can’t establish a connection to the server at localhost:8000.

我错过了什么?

先感谢您

django docker
  • 1 个回答
  • 190 Views
Martin Hope
user977828
Asked: 2018-12-30 18:04:01 +0800 CST

docker run 找不到软件参数

  • 1

我使用了以下命令,但由于某些原因,它找不到参数。

$ ls lachesis.ini 
lachesis.ini
$ docker run -it 5071f1ab27a0 /usr/local/bin/Lachesis lachesis.ini
RunParams is parsing INI file at lachesis.ini
ERROR: Can't find file lachesis.ini

我错过了什么?

先感谢您,

docker
  • 1 个回答
  • 40 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve