简体   繁体   中英

Docker inside wsl2 and Docker desktop differences

I have win 10 and wsl2. I have docker-compose like this:

nginx:
image: nginx:latest
container_name: nginx
ports:
  - 80:80
volumes:
  - ./nginx/conf:/etc/nginx/conf.d
  - ./nginx/www:/var/www
  - ./nginx/logs:/var/log/nginx
domainname:
  dock.test
links:
  - php
  - db
networks:
  my:
    aliases:
      - dock.test

In case when docker daemon is on windows side (Docker Desktop) site opens by URL dock.test. But if i stop Docker desktop and start docker in wsl like sudo service docker start site is not available by domain dock.test (chrome error 'connection refused', not nginx error), but available by localhost (2 domains configured in nginx). It seems to me like docker in wsl doesnt know anything about dock.test . Can anyone help me? Thanks

I dont know how it works but when i put this lines in windows hosts file it works fine

127.0.0.1 dock.test
::1 dock.test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM