【发布时间】:2019-06-15 12:35:31
【问题描述】:
我刚开始学习 docker 并尝试根据我的需要调整它。 给定这么简单的 docker-compose 文件
version: '3'
services:
my-client:
container_name: my-client
build:
context: ./client
dockerfile: Dockerfile_dev
ports:
- "3000:3000"
volumes:
- ./client/src:/srv/dev/client/src
- ./client/public:/srv/dev/client/public
command: npm run start
my-nginx:
container_name: my-nginx
build: ./nginx
links:
- my-client
expose:
- 80
ports:
- "80:80"
(nginx 只是代理对客户端的请求)
目前我可以通过localhost和localhost:3000访问我的客户端,这不好。我希望只有 1 个端口在我的网络之外可见,并隐藏所有其他容器。是否可以以outside->nginx->client而不是outside->client时的方式设置网络
【问题讨论】:
-
不知道为什么有人将此问题标记为无用。在我看来,OP 作为初学者提出了一个非常有效的问题。
标签: docker docker-compose docker-networking