When I try running a container with a volume that I created on WSL2, it fails to start.
Creating the volume and container with the exact same syntax on a full Ubuntu machine works just fine.
What am I doing wrong?
docker volume create ubu-vol
ubu-vol
docker run -it -d -v ubu-vol --name ubu-dev ubuntu /bin/bash
87ee4245f4022d1cf26da32fd701d768d449f679b4441b5bf734d834d9ccf190 docker: Error response from daemon: OCI runtime create failed: invalid mount {Destination:ubu-vol Type:bind Source:/var/lib/docker/volumes/123784ee61e4bc2a77f98e6574ae6c71c4cc7fa6f7e109ac55f8f115df07eba5/_data Options:[rbind]}: mount destination ubu-vol not absolute: unknown.
Running the container without specifying the volume works fine in WSL2.
docker run -it -d --name ubu-dev ubuntu /bin/bash
The container starts, and I can attach to it just fine.
I've also tried being more specific with the volume's path (since the error said it needed to be absolute), but I get the same result.
docker volume create \
--driver local \
--opt type=nfs \
--opt device=:/mnt/d/docker-vol \
ubu-vol
Perhaps it means something different by "absolute path?"
I'd appreciate any insight that you might have.
Your --volume/-v
syntax doesn't look right. You aren't specifying the path where it should be mounted inside the container.
Try:
docker run -it -d -v "ubu-vol:/mnt/docker-ubu-vol" --name ubu-dev ubuntu /bin/bash
But also consider that Docker recommends using the newer --mount
option:
docker run -it -d --mount "type=volume,src=ubu-vol,dst=/mnt/docker-ubu-vol" --name ubu-dev ubuntu /bin/bash