Goal Set up a test environment to replicate a web server using Docker running a GO application
What I have done so far
FROM golang:alpine as unwindtest
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOFLAGS=-mod=mod
COPY . /app/
WORKDIR /app/
RUN ls -al
EXPOSE 8010
RUN go install -v github.com/some1/some2
RUN go build -v .
docker build -t unwindtest:$BUILD_NUMBER .
docker run --env-file ./env.list --rm -it -p 8010:8010 unwindtest:$BUILD_NUMBER
/app # /go/bin/<name of binary/app>
I expose the port as change the nfw settings with sudo ufw allow 8010/tcp
docker ps -a also shows something as below
290c17f5d54b unwindtest:0.0.2 "/bin/sh" 13 days ago Up 13 days 0.0.0.0:8010->8010/tcp affectionate_mendel
root@whatever# netstat -plant | grep 8010
tcp6 0 0 :::8010 :::* LISTEN 136450/docker-proxy
<ip>:8010
How do I expose and run this GO application on the localhost as http:\\<ip>:port , or simply put am I missing any steps here?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
I think that with the current Dockerfile you are just building the executable but not running it.
I believe that you should add a CMD command at the end:
# Run the executable
CMD ["./your-go-app"]
That way when you run the container it will actually start the Go application as well.
Besides that, all the other things that you’ve shared look good.
Let me know how it goes! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.