Tag: django

如何在Docker上的页面重新加载后更新修改?

我有一个使用Docker的问题,我想更新我的页面上的更改,只要我更改我的CSS文件,而不是重新启动所有容器在docker上。 每当我保存一个HTML页面的变化是自动进行,但不知何故,每当我改变一个静态文件的东西不按计划工作。 我在Windows和Django上使用Docker Toolbox。 Docker-compose.yml: version: '2' services: nginx: restart: always image: nginx:latest container_name: NGINX ports: – "8000:8000" volumes: – ./src:/src – ./config/nginx:/etc/nginx/conf.d – /static:/static – /media:/media depends_on: – web web: restart: always build: . container_name: DJANGO command: bash -c "python manage.py collectstatic –noinput && python manage.py makemigrations && python manage.py migrate && gunicorn oqtor.wsgi […]

使用Django和Docker从MySQL迁移到postgresql – 关系“authtoken_token”不存在

我正在尝试使用MySQL数据库将我的Django项目迁移到使用Docker的postgresql。 当我使用MySQL时,一切正常。 我有所有在ORM,所以当我使用MySQL时,我必须创build唯一的数据库和做的python manage.py makemigrations ,然后python manage.py migrate ,我准备好所有关系的数据库。 正如我所提到的,我试图使用postgresql数据库。 服务器似乎工作正常使用docker-compose up ,但是当我发送实例GET请求我得到: ProgrammingError at /data relation "authtoken_token" does not exist LINE 1: …user"."is_active", "auth_user"."date_joined" FROM "authtoken… 我的设置: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': 'postgres', 'HOST': 'db', 'PORT': 5432, } } 我docker-compose.yml : version: '3' services: db: image: postgres web: build: […]

在Docker中用Angular 4,Django和postgresql部署项目

我想部署在Heroku我的项目在Docker Angular 4前端与Django后端和postgresql数据库。 在这个时候我的文件看起来如下所示。 我记得确定这是否正确完成? 我使用heroku container:push web –app myproject推送它heroku container:push web –app myproject但它不起作用(日志)。 我假设如果我使用Docker,我不必创buildProcfile等? 可能错误是由于数据库迁移不足造成的? 我不知道我正在走向正确的方向,但我正在尝试迁移我的数据库。 也许我的错误是由缺乏数据库引起的? 当我运行heroku run python manage.py migrate ,我得到: django.db.utils.OperationalError:无法将主机名“db”翻译为地址:名称或服务未知 日志: 2017-07-07T10:27:30.448951+00:00 heroku[web.1]: State changed from crashed to starting 2017-07-07T10:27:30.436282+00:00 heroku[web.1]: Process exited with status 0 2017-07-07T10:27:50.846928+00:00 heroku[web.1]: Starting process with command `python3` 2017-07-07T10:27:53.350381+00:00 heroku[web.1]: Process exited with status 0 […]

Docker + Django + Angular + Heroku + Postgresql – 进程退出状态127,错误代码= H10 desc =“应用程序崩溃”

我想部署在Heroku我的项目在Docker与Angular 4前端,Django后端和postgresql数据库。 在这个时候我的文件看起来如下所示。 我记得确定这是否正确完成? 我使用heroku container:push web –app myproject推送它heroku container:push web –app myproject但它不起作用(日志)。 当我运行docker-compose up没有Heroku一切似乎正常工作。 我注意到在日志中有Process exited with status 127 。 我在这里find127返回码$? 那 Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't […]

部署在Heroku dockerized Web应用程序 – 错误代码= H14 desc =“没有web进程运行”

我想部署在Heroku我的项目在Docker与Angular 4前端,Django的后端和postgresql数据库。 在这个时候我的文件看起来如下所示。 在活动中,我有信息, Build succeeded但是在日志中我得到错误at=error code=H14 desc="No web processes running" method=GET path="/" host=myapp request_id=fe4c4613-7c39-49c2-a354-ee1f195de922 fwd="109.173.154.199" dyno= connect= service= status=503 bytes= protocol=https 我发现我应该尝试heroku ps:scale worker=1但我得到的信息Couldn't find that process type. 任何build议或其他想法如何平滑error code=H14 ? 项目树: ├── Backend │ ├── AI │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── […]

通过Python中的Docker API设置login

我正在尝试Docker API python库,但无法获得一点成功,通过文档。实际上我试图login到使用API​​的docker。 这是我的Python代码: import docker config = os.path.join(BASE_DIR, 'IGui') + 'config.json' client = docker.APIClient.login('username', '*******', 'email@gmail.com','https://index.docker.io/v1/', config) 这是我收到的错误: AttributeError at /gui/docker/ 'str' object has no attribute '_auth_configs' Request Method: POST Request URL: http://127.0.0.1:8000/gui/docker/ Django Version: 1.11.3 Exception Type: AttributeError Exception Value: 'str' object has no attribute '_auth_configs' Exception Location: /Users/abdul/IstioVirEnv/lib/python3.6/site- packages/docker/api/daemon.py in login, line […]

Django – 在本地和Heroku上都找不到静态文件

我在使用Django和Heroku上的Docker的静态文件时遇到问题。 当我打开应用程序,我在Heroku上得到这样的错误: 2017-07-13T13:37:43.271635+00:00 heroku[router]: at=info method=GET path="/static/rest_framework/js/default.js" host=myapp.herokuapp.com request_id=3bfd8d31-193e-48e8-bb6e-aee9f353ffee fwd="109.173.154.199" dyno=web.1 connect=1ms service=15ms status=404 bytes=291 protocol=https 在本地就像这样: django_1 | [13/Jul/2017 13:35:01] "GET /static/rest_framework/js/default.js HTTP/1.1" 404 109 我试图做很多答案的基础上,例如这个主题 ,不幸的是没有任何工作。 有什么build议么? 基于Heroku文档的我的settings.py : PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, 'static'), ) STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' 我添加了whitenoise到requirements.txt 。 wsgi.py: import os […]

芹菜吃了记忆

我在aws上有一个t2.medium实例。 我的两个Python应用程序和他们的芹菜工作人员在不同的docker集装箱内运行。 共有4个容器正在运行。 无缘无故,芹菜吃了很多实例的记忆。 ps命令输出的屏幕截图 我已经检查过,django正在运行DEBUG_MODE False。 我已经将worker_max_tasks_per_childconfiguration为200,将worker_max_memory_per_childconfiguration为200MB。 我有: Ubuntu版本:16.04 Python版本:3.5 截至目前,我没有执行任何任务,仍然吃掉实例内存。 请帮我debugging问题。 芹菜报告的输出 软件 – >芹菜:4.0.2(latentcall)kombu:4.0.2 py:3.5.2台球:3.5.0.2 py-amqp:2.1.4 平台 – >系统:Linux arch:64bit,ELF imp:CPython loader – > celery.loaders.default.Loader 设置 – >运输:amqp结果:禁用

从GitHub仓库build立Docker镜像

我正在尝试使用docker api python客户端从GitHub存储库构builddocker镜像。 以下是我所尝试的: 从views.py if request.method == 'POST': post_data = request.POST.copy() post_data.update({'user': request.user.pk}) form = TarFromGithubForm(post_data) if form.is_valid(): deployment = gitHubModel() deployment.name = form.cleaned_data['name'] deployment.user = request.user deployment.archive = form.cleaned_data['archive'] dpath = deployment.archive print(deployment.archive) deployment.save() tag = deployment.name.lower() client = docker.from_env() client.images.build(path=dpath, tag=tag) messages.success(request, 'Your deployment from github repository has been created successfully!') return […]

从容器到主机docker的容量共享 – 组成

我试图在容器和主机之间共享数据。 所以我只是想做这个来存储容器文件。 数据必须从容器共享到主机。 我的docker-compose.yml version: "3.3" services: django: image: python:slim volumes: – type: volume source: ./env target: /usr/local/lib/python3.6/site-packages volume: nocopy: true – ./src:/usr/src/app ports: – '80:80' working_dir: /usr/src/app command: bash -c "pip install -r requirements.txt && python manage.py runserver" 当我运行docker时会抛出: 错误:对于Django无法创build容器的服务django:无效的绑定安装规范“/Users/gustavoopb/git/adv/env:/usr/local/lib/python3.6/site-packages:nocopy”:无效的卷规范:“ /Users/gustavoopb/git/adv/env:/usr/local/lib/python3.6/site-packages:nocopy':types为“bind”的无效装载configuration:字段不能指定VolumeOptions错误:遇到错误该项目。 https://docs.docker.com/compose/compose-file/#long-syntax-3