无法通过curl或Postman访问docker URL

编程入门 行业动态 更新时间:2024-10-24 20:11:52
本文介绍了无法通过curl或Postman访问docker URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以使用以下路径在浏览器中访问我的网站:my-dash.docker.localhost:8000

I can access my site in the browser with the following path: my-dash.docker.localhost:8000

我正在尝试编写API端点,并且可以

I am trying to write an API endpoint and can't access the site via Postman or curl.

curl my-dash.docker.localhost:8000 curl: (6) Could not resolve host: my-dash.docker.localhost

这是我的docker-compose .yml:

This is my docker-compose.yml:

version: "2" services: mariadb: image: wodby/mariadb:10.1-2.1.0 environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: drupal MYSQL_USER: drupal MYSQL_PASSWORD: drupal volumes: - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here. php: image: wodby/drupal:8-7.1-2.1.2 environment: PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 DB_HOST: mariadb DB_USER: drupal DB_PASSWORD: drupal DB_NAME: drupal DB_DRIVER: mysql PHP_XDEBUG: 1 PHP_XDEBUG_DEFAULT_ENABLE: 1 PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254' volumes: - mydash-sync:/var/www/html:nocopy # Docker-sync for macOS users nginx: image: wodby/drupal-nginx:8-1.10-2.1.0 depends_on: - php environment: NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off" NGINX_ERROR_LOG_LEVEL: debug NGINX_BACKEND_HOST: php NGINX_SERVER_ROOT: /var/www/html/web volumes: - mydash-sync:/var/www/html:nocopy # Docker-sync for macOS users labels: - 'traefik.backend=nginx' - 'traefik.port=80' - 'traefik.frontend.rule=Host:my-dash.docker.localhost' solr: image: wodby/drupal-solr:8-6.4-2.0.0 environment: SOLR_HEAP: 1024m labels: - 'traefik.backend=solr' - 'traefik.port=8983' - 'traefik.frontend.rule=Host:solr.my-dash.docker.localhost' mailhog: image: mailhog/mailhog labels: - 'traefik.backend=mailhog' - 'traefik.port=8025' - 'traefik.frontend.rule=Host:mailhog.my-dash.docker.localhost' traefik: image: traefik command: -c /dev/null --web --docker --logLevel=INFO ports: - '8000:80' - '8080:8080' # Dashboard volumes: - /var/run/docker.sock:/var/run/docker.sock volumes: mydash-sync: external: true

推荐答案

您必须编辑 / etc / hosts 文件,才能使计算机解析该名称。将此添加到文件末尾:

You have to edit your /etc/hosts file to get your computer resolving that name. Add this at the end of the file:

127.0.0.1 my-dash.docker.localhost

更多推荐

无法通过curl或Postman访问docker URL

本文发布于:2023-10-29 04:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538672.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Postman   curl   URL   docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!