doublebyte
doublebyte

Reputation: 1275

Dockerize Applications or Machines?

I apologize if my question is too basic, but I just started to learn docker and there are some concepts that are not clear to me.

I think of docker as a fully functional virtual machine, and therefore I thought of transforming a server with a set of services, into a container. Then I started reading about "dockerizing" applications (for instance postgresql), and I learned that a Docker file can only have one default instruction, when executing a container. I read that it is possible to coordinate multiple executing instructions using a supervisor, but I started wondering if that is really the best approach, or if it would be better to lean towards a microservices architecture?

To state better my point, I would like to describe my use case. I want to create an environment that provides tomcat (with some services deployed through servlets) and a postgreSQL database. Ideally, I would like the services (and the database), to run in the same host (on different ports).

Is it a best practice to create one container for Tomcat and one for the Database, or is it better to ship them in the same container?

And if I create two different containers, which framework should I use to orchestrate them? Is it Docker compose appropriated for this task?

Upvotes: 0

Views: 274

Answers (1)

ashatrov
ashatrov

Reputation: 1112

1)

I think of docker as a fully functional virtual machine, and therefore I thought of transforming a server with a set of services, into a container.

NO NO and NO! It is not virtual machine

Run only one process per container

In almost all cases, you should only run a single process in a single container. Decoupling applications into multiple containers makes it much easier to scale horizontally and reuse containers. If that service depends on another service, make use of container linking.

Read Best practices for writing Dockerfiles https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/

2)

And if I create two different containers, which framework should I use to orchestrate them? Is it Docker compose appropriated for this task?

You need to start with docker-compose. When you will be more familiar with it you make you own well-founded decision.

Upvotes: 3

Related Questions