@labsvisua covered most of it.
Docker essentially tries to package applications in such a way that you'll never get, "but it works on my machine" type of problems.
With Java, you package all your Jar files into a WAR file if you're building a web application, with Docker you now take that WAR file and package it with Tomcat in a Docker image, so that when you run it, the exact version of Tomcat it needs is already included as well as the exact version of Java that it was tested on instead of testing it on Oracle Java8 on your dev machine and having to run it on OpenJDK Java7 on your server.
Same for PHP as another example, instead of taking your PHP code that was working in PHP5.5 and uploading it to the server which has another version of PHP included, package the correct version of PHP with your code, package Apache2.4 with it if that is what you've tested it on and when you run it on the server, it will run in the same environment than what you've tested on.
Using docker, you can also start leveraging things like Kubernetes to utilise your instances to the max instead of having many instances all running at 30% capacity.