skip to Main Content

While mount a host folder with static content into a Docker Nginx container, I am getting the below error:

docker: Error response from daemon: invalid mode: usrsharenginxhtml.

I am running this command:

docker run --name website -v $(C:UsersUSERDesktopwebsite):usrsharenginxhtml -d -p 8080:80 nginx

2

Answers


  1. Image in nginx is Linux based so location mapping is little different then windows, use :/usr/share/nginx/html/. It uses forward slash rather then backward slash.

    Login or Signup to reply.
  2. Try

    docker run --name website -v C:UsersUSERDesktopwebsite:/usr/share/nginx/html -d -p 8080:80 nginx
    

    For the Windows path, use backslash and for the Linux path use forward slash. The $(xxx) notation you used is a Linux thing that takes the output of a command and puts it into the command. It’s often used with pwd where $(pwd) gets the current directory. You can do the same in Windows CMD with %cd%. In your case it would be

    docker run --name website -v %cd%:/usr/share/nginx/html -d -p 8080:80 nginx
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search