Question: I am building a golang WebService in docker. The build seems fine but I am unable to expose the port for external (outside of container) access. When I curl from the command line (inside the container) the app appears to work fine. 

I saw quite a few posts of similar problems but unfortunately many were not resolved or didn't seem applicable.

```
FROM golang:alpine
RUN mkdir /go/src/webservice_refArch
ADD . /go/src/webservice_refArch
WORKDIR /go/src/webservice_refArch
RUN apk add curl
RUN cd /go/src/webservice_refArch/ && go get ./...
RUN cd /go/src/webservice_refArch/cmd/reference-w-s-server && go build -o ../../server
EXPOSE 7878
ENTRYPOINT ["./server", "--port=7878"]

```

I have tried both: 

* :7878
* localhost:7878

Answer: 
See <https://docs.docker.com/engine/reference/run/#expose-incoming-ports>, just expose port in dockerfile is not enough.

You can add `-p 7878:7878` when start container, or use `-P` to let docker set a automatical host port mapping for you.

If you do not want to do above, you can also add `--net=host` when start the container, then container will use host's network, if also works for you.
if you are trying to access the port inside your docker container from your local machine, you need map it to the desired port on your local machine
`docker run -p 7878:7878 IMAGE`
Then you should be able to access it on your host