我不能杀死或停止任何码头集装箱.我允许非特权用户运行Docker命令.并且docker run hello-world
工作正常.但我不能阻止任何其他容器.
我得到了以下:
$ docker stop 59e3b815d1dc
Error response from daemon: cannot stop container: 59e3b815d1dc:
Cannot kill container 59e3b815d1dcf2d8c8bcd3dd641c3c033b83ac68ea2f0257a32a76468af7374c:
unknown error after kill: docker-runc did not terminate sucessfully:
container_linux.go:393: signaling init process caused "permission denied"
: unknown
Run Code Online (Sandbox Code Playgroud)
与sudo相同的错误.同时,所有容器都成功运行,但要停止它们只能完全重启系统.
Docker撰写示例:#使用postgres/example用户/密码凭证版本:'3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080
Run Code Online (Sandbox Code Playgroud)
Docker信息:
$ docker info
Containers: 7
Running: 2
Paused: 0
Stopped: 5
Images: 10
Server Version: 17.12.1-ce
Storage Driver: overlay2
Backing …
Run Code Online (Sandbox Code Playgroud) 我将项目从Django 1.6.7更新到1.8.7并且我在Django 1.8中有以下异常,尽管使用Django 1.6它的代码是正确的:
In[2]: from apps.route import models
In[3]: models.Trace.objects.select_related("trace_points")
Out[3]: <repr(<django.db.models.query.QuerySet at 0x3b50c10>) failed: django.core.exceptions.FieldError: Invalid field name(s) given in select_related: 'trace_points'. Choices are: user>
Run Code Online (Sandbox Code Playgroud)
我的模特:
class Trace(SocialMixin, models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='traces')
name = models.CharField(u'????????', max_length=255)
rating = RatingField(range=5, weight=0)
start_date = models.DateTimeField(u'???? ??????')
finish_date = models.DateTimeField(u'???? ?????????', null=True, blank=True)
distance = models.DecimalField(max_digits=15, decimal_places=6, null=True, blank=True)
created = models.DateTimeField(auto_now_add=True)
hits = generic.GenericRelation(HitCount, object_id_field='object_pk')
description = models.TextField(null=True, blank=True)
class TracePoint(models.Model):
country = models.ForeignKey(Country, null=True, blank=True)
city = models.ForeignKey(City, …
Run Code Online (Sandbox Code Playgroud) bulk_create与ignore_conflicts=True
只插入新记录,并且不更新现有之一。
bulk_update只更新现有记录,不插入新记录。
现在我只看到一个用于 upsert 的变体是一个原始查询:
from catalog.models import Product
with connection.cursor() as cursor:
cursor.executemany(
"""
INSERT INTO app_table (pk, col1, col2)
VALUES (%s, %s, %s)
ON DUPLICATE KEY UPDATE
col1 = VALUES(col1),
col2 = VALUES(col2);
""",
[
('1', 'val1', 'val2'),
('2', 'val1', 'val2'),
]
)
Run Code Online (Sandbox Code Playgroud)
有没有另一种方法可以在 Django 中执行批量 upsert?