我可以使用以下路径在浏览器中访问我的网站: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
答案 0 :(得分:2)
您必须编辑/etc/hosts
文件才能让您的计算机解析该名称。在文件末尾添加:
127.0.0.1 my-dash.docker.localhost