docker (windows10 wsl2) unable to mount ./nginx/conf.d:/etc/nginx/conf.d

Viewed 361

i try to map ./nginx/conf.d:/etc/nginx/conf.d, the following are the commands in the yml

volumes:
  - ./nginx/nginx.conf:/etc/nginx/nginx.conf
  #- ./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
  #- ./nginx/conf.d/docker1.example.com.conf:/etc/nginx/conf.d/docker1.example.com.conf      
  #- ./nginx/conf.d/docker2.example.com.conf:/etc/nginx/conf.d/docker2.example.com.conf      
  - ./nginx/conf.d:/etc/nginx/conf.d
  - ./src:/var/www

In the image, under /etc/nginx/conf.d, there is a default.conf exists, when i run docker-compose up, it try to make a directory named default.conf, so the nginx starts with error

I also tried to create ./nginx/conf.d/default.conf first before running the command in local directory, but still not work.

Anyone know how to map ./nginx/conf.d:/etc/nginx/conf.d in correct way?

1 Answers

It appears you are doing it the right way, except for a small, annoying bit:

When mapping the content between the two locations, you should make sure the sintax is correct /:/ when separating the two.

volumes:
  - ./nginx/nginx.conf/:/etc/nginx/nginx.conf
  - ./nginx/conf.d/default.conf/:/etc/nginx/conf.d/default.conf
  - ./nginx/conf.d/docker1.example.com.conf/:/etc/nginx/conf.d/docker1.example.com.conf      
  - ./nginx/conf.d/docker2.example.com.conf/:/etc/nginx/conf.d/docker2.example.com.conf      
  - ./nginx/conf.d/:/etc/nginx/conf.d
  - ./src/:/var/www
Related