Skip to content

Binding volume to specific host path doesn't work #3316

Open
@abbaahmad

Description

@abbaahmad

I'm attempting to create a container with volume in some host path /home/ubuntu/data bound to a container path /mnt/data, but the volume is instead created and bound to var/lib/docker/vfs/<some-hash>/home/ubuntu/data. Is there something I might be missing here? Here is the related code-snippet

   _ = docker.containers.run(
        image=image.id,
        command=f"{args}",
        name=c.DOCKER_IMAGE_NAME,
        restart_policy={"Name": "always"},
        volumes={f"{c.DATADIR_PATH.as_posix()}": {"bind": "/mnt/data", "mode": "rw"}},
        ports={"5432": ("0.0.0.0", 5432), "5433": ("0.0.0.0", 5433)},
        detach=True,
    )

DATADIR_PATH=/home/ubuntu/data. One thing to note is DATADIR_PATH of of type Path from pathlib module

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions