小编Sim*_*n L的帖子

Docker运行结果报错:层不存在

我正在尝试使用 docker-compose 在我的 raspberry pi 3 上设置 redmine(使用 postgres)。它已经工作过一次,但后来我尝试安装插件并以某种方式设法使我的系统崩溃。

现在它不再让我启动我的数据库容器。即使创建一个新postgres:12.8容器,也会产生错误layer does not exist

$ docker run --rm -it postgres:12.8 bash
docker: Error response from daemon: layer does not exist.
Run Code Online (Sandbox Code Playgroud)

我已经重新启动系统两次,遗憾的是没有改变任何东西。我怎样才能让它再次工作?

附加信息:

$ docker info
Client:
 Debug Mode: false

Server:
 Containers: 5
  Running: 4
  Paused: 0
  Stopped: 1
 Images: 65
 Server Version: 19.03.13
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge …
Run Code Online (Sandbox Code Playgroud)

docker

9
推荐指数
2
解决办法
2万
查看次数

如何接受子类中的附加参数?(没有pylint的论点 - 不同)

我有一个代表游戏状态的基类并提供了一个perform_move方法:

class GameState:
  # other code
  def perform_move(self, position: LinePosition) -> MoveResult:
    # more code
Run Code Online (Sandbox Code Playgroud)

现在我想创建一个GameState跟踪玩家分数的子类。因为基类不关心玩家(关注点分离),所以我需要一个额外的参数来识别正在执行移动的玩家。我尝试了以下方法:

class ScoreKeepingGameState(GameState):
  # other code
  def perform_move(self, position: LinePosition, *, player_identification: Optional[int] = None) -> MoveResult:
    # more code
Run Code Online (Sandbox Code Playgroud)

我希望这能奏效,因为我可以调用ScoreKeepingGameState'sperform_move完全没问题player_identification,唉 pylint 抱怨:

W0221:参数不同于重写的“perform_move”方法(参数不同)

是否有比添加# pylint: disable=arguments-differ到 的perform_move定义更清洁的方法来满足 pylint ScoreKeepingGameState

python pylint python-3.x

5
推荐指数
1
解决办法
2382
查看次数

为什么 python 在 docker 容器内速度较慢?

下面的小代码片段计算了添加一堆数字所需的时间。

import gc
from time import process_time_ns

gc.disable() # disable garbage collection
for func in [
    process_time_ns,
]:
    pre = func()

    s = 0
    for a in range(100000):
        for b in range(100):
            s += b
    print(f"sum: {s}")

    post = func()
    delta_s = (post - pre) / 1e9 # difference in seconds
    print(f"{func}: {delta_s}")
Run Code Online (Sandbox Code Playgroud)

令我惊讶的是,在 docker 容器内运行时(约 1.6 秒)比直接在主机上运行时(约 0.8 秒)花费的时间要长得多。经过一番挖掘,我发现 docker 的一些安全功能可能会导致速度变慢(https://betterprogramming.pub/faster-python-in-docker-d1a71a9b9917https://pythonspeed.com/articles/docker-performance-overhead/)。事实上,添加 docker 参数--privileged仅减少了约 0.9 秒的运行时间。然而,我仍然对我观察到的约 0.1 秒的差距感到困惑,这并没有出现在文章中。我已将 CPU 频率设置为 3000MHz,并将 python 执行修复为在核心 0 …

python docker

4
推荐指数
1
解决办法
1746
查看次数

如何使用css强制html元素在一行中显示?

我想只使用html和css(没有javascript)制作菜单.它应该有几个彼此相邻的链接和一个滚动条 - 一个HORIZONTAL滚动条 - 所以可以访问所有链接.

我无法弄清楚如何强制这些链接显示在彼此旁边,而不是中断和显示在另一行.我现在的untiol看起来像这样:jsfiddle

HTML: <nav> <a>Site1</a> <a>Site2</a> <a>Site3</a> ... <a>Site17</a> <a>Site18</a> <a>Site19</a> </nav

CSS: nav { position: fixed; top: 0; left: 0; height: 100; background: #c00; overflow-x: scroll; overflow-y: hidden; }

编辑:解决方案是添加white-space: nowrap到CSS.的jsfiddle

html css html5 css3

1
推荐指数
1
解决办法
1247
查看次数

标签 统计

docker ×2

python ×2

css ×1

css3 ×1

html ×1

html5 ×1

pylint ×1

python-3.x ×1