1

I have project that uses Go and postgresql

What is the optimal solution for creating a DockerFile?

use os[for example ubuntu] in docker and install go and postgresql? or use those separately[use go and postgresql and connection between them]?

1 Answer 1

4

Docker suggest one container for one task, you could refers to Multi container apps:

We have been working with single container apps. But, we now want to add MySQL to the application stack. The following question often arises - “Where will MySQL run? Install it in the same container or run it separately?” In general, each container should do one thing and do it well. A few reasons:

  • There’s a good chance you’d have to scale APIs and front-ends differently than databases
  • Separate containers let you version and update versions in isolation
  • While you may use a container for the database locally, you may want to use a managed service for the database in production. You don’t want to ship your database engine with your app then.
  • Running multiple processes will require a process manager (the container only starts one process), which adds complexity to container startup/shutdown

And there are more reasons. So, we will update our application to work like this:

enter image description here

So, for you, you should choose use go and postgresql in different containers and connection between them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.