继续运行Docker容器内的GO HTTP服务器应用
我有一个docker
仅运行go
我创建的二进制文件的容器,它是带有gin
Framework的HTTP服务器。我不使用任何其他Web服务器,只需GO的内部HTTP服务器即可。在我的dockerfile
在文件末尾我有:
EXPOSE 80
CMD ["/home/project/microservices/backend/engine/cmd/main"]
我使用docker-compose
运行容器和重新启动:每个容器的始终
。而且有效!
但是我的问题是,如果我创建的HTTP服务器因编程错误或其他原因而失败,它将重新启动?我该如何检查? Docker有这样的工具吗?
我尝试使用Substisord
,但它存在一些问题,但我在运行它方面没有成功。
我希望有能力将HTTP服务器保持在容器内始终运行。
我能做些什么?
I have a Docker
container that runs just a Go
binary I created that is a http server with Gin
framework. I don't use any other Web Server, just Go's internal http server. Inside my Dockerfile
at the end of file I have this:
EXPOSE 80
CMD ["/home/project/microservices/backend/engine/cmd/main"]
I use docker-compose
to run the container and restart: always
for each container. And it works!
But my question is that, if the http server that I created fails due to programming error or something, It will restart? how can I check this? does Docker has tools for this?
I tried go with Supervisord
but it has some problems and I was not successful on running it.
I want a workaround to keep the http server inside container always running.
What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试从主机杀死该过程。使用类似的内容找到过程ID
,然后使用Docker杀死它,
然后将其重新启动。通过使用,
您应该看到“状态”已更改为
UP 10秒
之类的东西。You can try killing the process from the host. Find the process id using something like
Then kill it using
Docker will then restart it. By using
you should see that the 'status' has changed to something like
Up 10 seconds
.