我正在尝试在 Docker 容器中启动并运行 Neo4J 数据库。 目前我使用以下命令运行它:
docker run -d -p 7474:7474 -p 7687:7687 neo4j
..并且工作正常。
我想将其放入 Dockerfile 中,以便我可以进行一些服务器配置,但是当我使用 Dockerfile 时,它不会公开我设置为公开的端口,除非我在执行“docker run”时明确公开它们“:
FROM neo4j
ENV NEO4J_AUTH neo4j/password
EXPOSE 7474:7474
EXPOSE 7687:7687
我是否误解了什么,或者端口不应该通过此配置自动公开?
最佳答案
The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. EXPOSE does not make the ports of the container accessible to the host. To do that, you must use either the -p flag to publish a range of ports or the -P flag to publish all of the exposed ports. You can expose one port number and publish it externally under another number.
To set up port redirection on the host system, see using the -P flag. The Docker network feature supports creating networks without the need to expose ports within the network, for detailed information see the overview of this feature).
关于Docker 和 Neo4J,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43173446/