Docker 撰写如何将容器挂载到已存在的新卷

Docker compose how to mount containers to new volume that already exists

我正在尝试将我的应用程序和 mongo 安装到新卷,因为现有卷上没有 space,但我仍然遇到同样的错误。有些事情我做得不对。我是新手docker,请指导

错误:

ERROR: write /var/lib/docker/tmp/GetImageBlob735048270: no space left on device

以下是我的docker撰写文件

version: "2"

    services:
      pim:
        build: .
        volumes:
           - pim-volume:.
        ports:
          - "5100:5100"
        links:
          - mongo
      mongo:
        container_name: mongo
        image: mongo
        volumes:
          - pim-volume:./data/db
        ports:
          - "27017:27017"
    volumes:
        pim-volume:
            external: true

以下是音量检查

[
    {
        "CreatedAt": "2019-12-22T09:08:50+04:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/pim-volume/_data",
        "Name": "pim-volume",
        "Options": {
            "device": "overlay",
            "o": "size=5GB",
            "type": "overlay"
        },
        "Scope": "local"
    }
]

您可能希望通过删除孤立的卷和图像来开始清理您的 space:

首先,检查您的孤立卷:

docker volume ls -qf dangling=true

您可以通过 运行ning 删除它们:

docker volume rm $(docker volume ls -qf dangling=true)

删除 old/unused 张图片 运行:

docker rmi $(docker images -q -f "dangling=true")