0

I am running Docker for Windows v19.03.12. I am running a linux container from Windows 10. I am sharing my entire c:\ drive with Docker (see image). I am trying to testing a container locally and need to pass a credentials file to the container.

When I run the following command:

docker run --rm -p 9215:80 -p 44371:443 --name test -t createshipment:latest -v c:/temp:/data  

When I explore the container I do not see a /data folder at all (see image).

enter image description here

I am not sure what else to try to share a folder when testing docker locally.

ProfessionalAmateur
  • 4,447
  • 9
  • 46
  • 63
  • 1
    It's probably because you included the volume info after the image name. Can you try with `docker run --rm -p 9215:80 -p 44371:443 --name test -t -v c:/temp:/data createshipment:latest` ? Note that `-t` allocates a pseudo-tty. It does not mean `--tag`, like it does in `docker build`. – jkr Sep 04 '20 at 17:59
  • You are 100% correct. It worked. If you post your answer below I will accept it. I've spent 2 days on this, and you solved it in 5 minutes, Im extremely appreciative. – ProfessionalAmateur Sep 04 '20 at 18:05

1 Answers1

1

The command docker run expects the image name as the last argument, before any arguments to the image's entrypoint. In the OP's post, the image name precedes the -v ... argument, so -v ... is actually passed to the image's entrypoint.

docker run --rm -p 9215:80 -p 44371:443 --name test -t \
  -v c:/temp:/data createshipment:latest

For the sake of completeness, here are the relevant excerpts from the documentation for the command-line options used here:

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

... 

    --name string     Assign a name to the container
-p, --publish list    Publish a container's port(s) to the host
    --rm              Automatically remove the container when it exits
-t, --tty             Allocate a pseudo-TTY
-v, --volume list     Bind mount a volume
jkr
  • 17,119
  • 2
  • 42
  • 68