Skip to main content
Post Deleted by CommunityBot
Post Locked by CommunityBot
Post Migrated Away to superuser.com by Ryan M
Post Closed as "Not suitable for this site" by Ryan M

I am learning docker,this is my dockerfile . I start a http service in docker and expose 9999 port,here is the content:

FROM golang:1.20 LABEL authors="tom"

WORKDIR /app

COPY . /app

RUN go build -o main .

EXPOSE 9999

ENTRYPOINT ["/app/main"]

FROM golang:1.20
LABEL authors="tom"

WORKDIR /app

COPY . /app

RUN go build -o main .

EXPOSE 9999

ENTRYPOINT ["/app/main"]

step 1 : I build the dockerfile to generate docker image called "cache-go". step

step 2 : I run the docker service by using:docker run --net=host -p 8899:9999 cache-go. step

step 3 : I test my web api in docker shell:curl "http://localhost:9999/api?key=Tom" , it's successful. step

step 4 : I try to access the web-api in my real host computer :"http://localhost:8899/api?key=Tom". failed

step1 to 3 are right,I tried to open the firewall and enable IpEnablerouting setting,but still failed. I'm confused about the problem,please help me, I will be appreciate for your help.

I tried to open the firewall and enable IpEnablerouting setting,but still failed.

I am learning docker,this is my dockerfile . I start a http service in docker and expose 9999 port,here is the content:

FROM golang:1.20 LABEL authors="tom"

WORKDIR /app

COPY . /app

RUN go build -o main .

EXPOSE 9999

ENTRYPOINT ["/app/main"]

step 1 : I build the dockerfile to generate docker image called "cache-go". step 2 : I run the docker service by using:docker run --net=host -p 8899:9999 cache-go. step 3 : I test my web api in docker shell:curl "http://localhost:9999/api?key=Tom" , it's successful. step 4 : I try to access the web-api in my real host computer :"http://localhost:8899/api?key=Tom". failed

step1 to 3 are right,I tried to open the firewall and enable IpEnablerouting setting,but still failed. I'm confused about the problem,please help me, I will be appreciate for your help.

I tried to open the firewall and enable IpEnablerouting setting,but still failed.

I am learning docker,this is my dockerfile . I start a http service in docker and expose 9999 port,here is the content:

FROM golang:1.20
LABEL authors="tom"

WORKDIR /app

COPY . /app

RUN go build -o main .

EXPOSE 9999

ENTRYPOINT ["/app/main"]

step 1 : I build the dockerfile to generate docker image called "cache-go".

step 2 : I run the docker service by using:docker run --net=host -p 8899:9999 cache-go.

step 3 : I test my web api in docker shell:curl "http://localhost:9999/api?key=Tom" , it's successful.

step 4 : I try to access the web-api in my real host computer :"http://localhost:8899/api?key=Tom". failed

step1 to 3 are right,I tried to open the firewall and enable IpEnablerouting setting,but still failed. I'm confused about the problem,please help me, I will be appreciate for your help.

I tried to open the firewall and enable IpEnablerouting setting,but still failed.

Source Link
tom
  • 1
  • 2

My windows host machine Can't access docker http service

I am learning docker,this is my dockerfile . I start a http service in docker and expose 9999 port,here is the content:

FROM golang:1.20 LABEL authors="tom"

WORKDIR /app

COPY . /app

RUN go build -o main .

EXPOSE 9999

ENTRYPOINT ["/app/main"]

step 1 : I build the dockerfile to generate docker image called "cache-go". step 2 : I run the docker service by using:docker run --net=host -p 8899:9999 cache-go. step 3 : I test my web api in docker shell:curl "http://localhost:9999/api?key=Tom" , it's successful. step 4 : I try to access the web-api in my real host computer :"http://localhost:8899/api?key=Tom". failed

step1 to 3 are right,I tried to open the firewall and enable IpEnablerouting setting,but still failed. I'm confused about the problem,please help me, I will be appreciate for your help.

I tried to open the firewall and enable IpEnablerouting setting,but still failed.