I am starting using Docker for my Kubuntu desktop. As I am following the tutorials, it has been helping me understanding how this works, but I am stuck with the following situation:

I would like to deploy containers for at least these three:

  • Web server (Apache)
  • SQL-compatible database (MariaDB/MySQL)
  • Java custom SDK (OpenSDK-based)

Searching for how-tos, people highly recommend using Alpine-based base images as they only use 5-6 MB of disk storage, which is pretty good. And that would solve my problems for the web server and the database as long as there are already made base images in the Docker Hub.

But the problem is with the Java SDK, where I just build my very own customized development environment which needs to use a Ubuntu 16.04 base image. (I could port it to Alpine, but there would be too many problems that I would not like to solve).

If I understood how Docker works, if multiple dockerfiles are using the same base image, this is not necessary to be downloaded again, as it would be used by every container that require it.

Then, would be a good idea to use that Ubuntu 16.04 base image to also deploy the web server and the database (and more containers, if any)? Because using the mentioned Alpine versions in the Docker Hub would need to download their Alpine base images too (even if they are only 5 MB).

Thanks in advance.

Just to clarify: I DO NOT want to change the tools I am currently using, that is not the question, I just want to understand Docker and good practices with it.


Yes, if you use the same base image for all three containers, you save on disk space, since that base layer is common to the three images. This said, Alpine isn't that big, so if your DB & Apache images are Alpine-based, this isn't as bad as it looks. But if you use a volume container (for instance to provide static content to the Apache server) you can base it on any of your existing images, and the only disk space it will use will be for the content you add.

  • This is exactly the answer I was looking for. Well, of course Alpine is tiny compared to Ubuntu, that is why I made the question. I have been installing and configuring these apps for long time over Debian-based systems, and in this scenario, I thought that could be a good reason to stay. I seem to have understood well how this Docker system works. Thanks again. – David Tabernero M. May 24 '18 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.