Question

How to deploy Go app alongside Nginx using Docker compose?

Hi,

I’m trying to follow this guide to deploy a Go app and Nginx using Docker Compose: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-go-web-application-with-docker-and-nginx-on-ubuntu-18-04

The problem I am having is that my Go application is stuck restarting indefinitely - it doesn’t seem to launch successfully. Nginx and Proxy Companion are running successfully, however. Furthermore,when I go to my domain, which is specified in the docker-compose file for the Go app, I am able to get to an https secured 502 bad gateway. I think this means the docker container for the Go app is being created successfully, but the actual web server isn’t able to listen on port 80. I created all of the Docker/Docker-Compose files to match the tutorial exactly so I’m not sure what the issue is. If I build the Docker file for my go application in isolation, without docker-compose, I can build and run the server. It’s just when I try to to use docker-compose it gets stuck in the restarting status. Any thoughts?


Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

In case that you have another service listening on port 80 it could prevent the Nginx container from starting.

You can check that with the following command:

netstat -plant | grep 80

If you have Nginx installed on your host, you would need to stop it and disable it before you run the docker-compose up command.

Regards, Bobby