Tag: python2.7

将Django连接到现有的Docker Postgres容器

我有我需要将我的Django项目连接到现有的Docker Postgres容器的情况。 简而言之,当我执行python manage.py dbshell ,django应该连接到现有的Docker Postgres容器。 目前我的Django连接到sqlite3数据库。 下面是我的settings.py片段连接到数据库。 DATABASES = { 'default': { # 'ENGINE': 'django.db.backends.postgresql_psycopg2', # 'NAME': 'etag_auth', # 'USER': 'etag_master', # 'PASSWORD': 'thisismypass', # 'HOST': 'cybercom_postgres', # 'PORT': '5432' 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } # 'etag': { # 'ENGINE': 'django.db.backends.postgresql_psycopg2', # 'NAME': 'etag', # 'USER': 'etag_master', # 'PASSWORD': 'thisismypass', # 'HOST': […]

运行exec时出错500,启动Docker Remote API

我正在使用Docker Remote Api和Python请求v2.2.1来运行一个exec语句。 这是我正在使用的代码: import requests import json containerName = 'my_container_name' startContainerRequest = requests.post('http://127.0.0.1:4243/containers/' + containerName + '/start') print startContainerRequest.status_code #result: 204 payload = {'Cmd':["date"]} headers = {'Content-type': 'application/json'} execCreateRequest = requests.post('http://127.0.0.1:4243/containers/' + containerName + '/exec', data=json.dumps(payload), headers=headers) print execCreateRequest.status_code #result: 201 execStartRequest = requests.post('http://127.0.0.1:4243/exec/' + execCreateRequest.json()['Id'] + '/start', headers=headers) print execStartRequest.status_code #result: 500 print […]