docker: Error response from daemon: invalid mode: \usr\share\nginx\html\

Viewed 850

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: \usr\share\nginx\html\.

I am running this command:

docker run --name website -v $(C:\Users\USER\Desktop\website):\usr\share\nginx\html\ -d -p 8080:80 nginx
2 Answers

Try

docker run --name website -v C:\Users\USER\Desktop\website:/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

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.

Related