Search code examples
dockerdocker-run

Docker named volumes not being created


I have a docker container that I am attempting to mount named containers to, however they do not appear to be getting created or mounted.

$ sudo docker run --network=host the_container \
            -v file_storage:/root/file_storage \
            -v redis_database:/var/lib/redis \
            -v mongo_database:/var/lib/mongodb

The container seems to run fine, however when I search for the containers, they are not being created and mounted, as they are supposed to.

$ sudo docker volume ls
DRIVER              VOLUME NAME
$

What am I doing wrong?


Solution

  • Everything after the image name on the docker run command is passed as a command to the container.

    Try it this way:

    sudo docker run --network=host \
                -v file_storage:/root/file_storage \
                -v redis_database:/var/lib/redis \
                -v mongo_database:/var/lib/mongodb \
                the_image