compose 文件的描述:我有一个 docker-compose.yml 文件,其中有一个名为“db”的服务。它在我的本地计算机上有一个卷“dbdata”,指向“/new/folder”。这被映射到容器的“/some/path/to/folder”路径。
以下是我的撰写文件的内容:
version: "3"
services:
db:
image: new:1
volumes:
- "dbdata:/some/path/to/folder"
ports:
- "1234:1234"
networks:
- webnet
volumes:
dbdata: /new/folder
networks:
webnet:
Run Code Online (Sandbox Code Playgroud)
问题:当我尝试通过发出以下命令来部署堆栈时:docker stack deploy --compose-file docker-compose.yml service_name,我收到错误“volumes.dbdata 必须是映射或 null”。
我也搜索了类似的查询,答案表明在 yaml 文件中,缩进必须正确。我确保撰写文件中的缩进正确。我尝试将 /new/folder 括在双引号内,删除 /new/folder 之前的额外空格。不幸的是,没有一个奏效。
问题:为什么存在错误“volumes.dbdata 必须是映射或为空”?我如何解决它?
概述:
在下面的代码中,我应该突出显示 id = "sample" 的 html 元素的最后一次出现,即“这是最后一段”。然而,“这是第一段”却被突出显示。
问题:
1)为什么 $("#sample:last").css("background-color", "yellow") 不突出显示最后一段?
2)当我更改为 $("p#sample:last").css("background-color", "yellow") 时,最后一段会突出显示。为什么这可行,而不是问题 1 中的场景?
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#sample:last").css("background-color", "yellow");
});
</script>
</head>
<body>
<p id="sample">This is the first paragraph.</p>
<p id="sample">This is the second paragraph.</p>
<p id="sample">This is the last paragraph.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)