gpt4 book ai didi

docker - 无法通过 curl 或 Postman 访问 docker url

转载 作者:行者123 更新时间:2023-12-01 13:33:01 25 4
gpt4 key购买 nike

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

我正在尝试编写 API 端点,但无法通过 Postman 或 curl 访问该站点。

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

这是我的 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 文件才能让您的计算机解析该名称。在文件末尾添加:

127.0.0.1 my-dash.docker.localhost

关于docker - 无法通过 curl 或 Postman 访问 docker url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44732448/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com