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:

  1. Pull three separate containers from the Docker hub and somehow use them together.
  2. Create a Dockerfile from scratch with all configurations.
  3. Pull three images from the Docker hub and manually create a single Dockerfile from them.

  • Is there a way to make docker containers truly fault-tolerant?
  • Creating a docker image for windows that requires execution of setup executables
  • Zypper repository authentication (non-interactive)
  • Docker container file permission changing Automatically
  • Building a docker image (.NET Core) and uploading it to Google Container Engine?
  • Why is docker failing to mount a volume and start on CentOS 7?
  • How to access tomcat server of windows to building Docker image from Docker file without downloading new tomcat?
  • docker-compose does not launch
  • Using nginx as a proxy to to java web servlet
  • How to run docker image with specific version and port forwarding
  • Can anyone explain docker.sock
  • Docker - Namespaces query [closed]
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.