Report this

What is the reason for this report?

How to deploy Go app alongside Nginx using Docker compose?

Posted on March 20, 2021

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?



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!

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.

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.