When I use the host mode
to run mycontainer, it doesn't work,but the bridge mode
works.I'd like to ask what's the different between the two modes?
Run with host mode
:
docker run --name=zhiwenyi --net=host -d [image]
Run with bridge mode
:docker run --name=zhiwenyi -d -p 35229:35229 [image]
Dockerfile:
FROM java:8
VOLUME /data/log/upload
COPY target/upload_V6_20220722.jar upload.jar
EXPOSE 35229
RUN bash -c "touch /upload.jar"
ENTRYPOINT ["java","-Xmx512m","-Xms512m","-jar","-Duser.timezone=GMT+08","-Dfile.encoding=utf-8","upload.jar"]
In bridge mode
, I send a post request
to myip:35229/path
,it works well.
In host mode
, the same request ,it shows me connection time out
.
Supply:
- OS:
centos 7.9
- Docker:
20.10.17