What is the best approach to configure Docker for a webapp?
I would like to configure a Docker container for running a Java application that uses Postgres and Jetty.
What is the best approach to do this:
- Pull three separate containers from the Docker hub and somehow use them together.
- Create a Dockerfile from scratch with all configurations.
- Pull three images from the Docker hub and manually create a single Dockerfile from them.
2 Solutions collect form web for “What is the best approach to configure Docker for a webapp?”
I’d like to point out that all three of your options are sort of valid… In your first option, that “somehow” you are referring to is the Compose. Your third option makes sense if you replace create a single Dockerfile from them with create a docker-compose.yml file for them.
I’m throwing this out there as an answer because I think it will help understanding of how different images can work together. It seems like you were naturally looking for Docker Compose.
A standard layout would be to use 2 containers – one for the database and one for the application (jetty with your Java application – I’m assuming it’s a WAR file)
Both should be based on standard containers readily available on Docker Hub.