我设置了2个项目(管理员和API),并尝试移至本地的docker。
我可以在两个实例上都访问正在运行的Web实例,但是当管理员尝试向API发出Curl请求时,出现了cURL错误:
cURL错误7:无法连接到本地主机端口8080
这是我的docker-compose.yml文件内容:
version: "3.1"
services:
memcached:
image: memcached:alpine
container_name: project-admin-memcached
redis:
image: redis:alpine
container_name: project-admin-redis
mariadb:
image: mariadb:10.1
container_name: project-admin-mariadb
working_dir: /application
volumes:
- ./Projects:/application
environment:
- MYSQL_ROOT_PASSWORD=docker
- MYSQL_DATABASE=db_test
- MYSQL_USER=test
- MYSQL_PASSWORD=test
ports:
- "8083:3306"
# docker-compose exec webserver sh
# docker exec -it project-admin-webserver nginx -s reload
webserver:
image: nginx:alpine
container_name: project-admin-webserver
working_dir: /application
volumes:
- ./Projects/Api:/application/api
- ./Projects/Admin:/application/admin
- ./Docker/nginx:/etc/nginx/conf.d
ports:
- "8080:8080"
- "8090:8090"
# docker-compose exec php-fpm bash
php-fpm:
build: Docker/php-fpm
container_name: project-admin-php-fpm
working_dir: /application
volumes:
- ./Projects:/application
- ./Docker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini
我可以使用以下方法从浏览器访问这两个项目:
http://localhost:8080/ <= API
http://localhost:8090/ <=管理员
我该如何解决?