邮递员中的Docker容器访问

邮递员中的Docker容器访问,docker,docker-compose,Docker,Docker Compose,我在docker compose.yml文件中有以下容器配置 networks: my-network: client-service: container_name: client-service image: client-service environment: - SPRING_PROFILES_ACTIVE=dev ports: - 8087:8087 restart: unless-stopped

我在
docker compose.yml
文件中有以下容器配置

  networks:
    my-network:

  client-service:
    container_name: client-service
    image: client-service
    environment:
      - SPRING_PROFILES_ACTIVE=dev
    ports:
      - 8087:8087
    restart: unless-stopped
    depends_on:
      - cassandra
    links:
      - cassandra
    networks:
      - my-network
我使用Docker 19版本和Mac OS。阅读材料后,在
/etc/hosts
文件中添加条目,如下所示

127.0.0.1 host.docker.local


- Close the connection if you have opened any for connecting to
   database after your work is done. Most of the times this is the
   reason. 

- You can handle this by using Async or Promise and SetTimeOut
   concepts which will make ur server to wait for response for a given
   time and if its taking too long just return with an error message.
   
- You can create multiple instances of your application on server and
   each instance will handle requests separately. 

- Also if you are developing a small utility you can modify it to fire limited 
   requests after a particular interval.

当我试图访问
http://host.docker.internal:8087
在邮递员中获取
套接字挂起
邮递员错误。我试过使用
localhost:8087
,但没有成功


mynetwork
是桥接网络。有没有办法访问我的容器?

我得到了解决
套接字挂起问题的方法,所以spring boot bean初始化了Cassandra连接,但没有关闭

在深入研究代码几天后,我忘记在
application.properties
文件中添加端口号。因此需要确保在
docker compose.yml
application.properties
文件中都添加端口。已经解决了

在您的情况下,可能是以下任何一个

127.0.0.1 host.docker.local


- Close the connection if you have opened any for connecting to
   database after your work is done. Most of the times this is the
   reason. 

- You can handle this by using Async or Promise and SetTimeOut
   concepts which will make ur server to wait for response for a given
   time and if its taking too long just return with an error message.
   
- You can create multiple instances of your application on server and
   each instance will handle requests separately. 

- Also if you are developing a small utility you can modify it to fire limited 
   requests after a particular interval.


容器内的进程是侦听端口8087还是其他地方?您可以使用
curl
或其他工具访问它吗?你的表演应该有用。(您无法直接访问网桥网络,在MacOS上,除了通过已发布的
端口:
之外,您根本无法访问容器)我的服务存在问题,由于DB连接,服务启动并失败,发生异常,再次使用同一端口启动。在阅读了Google的一些详细信息后,如果端口已经忙于某项服务,
套接字挂起