Different images in containers

I want to create separated containers with a single service in each (more or less). I am using the php7-apache image which seems to use a base image of debian:jessie, php7 and apache. Since apache and php in this case are pretty intertwined I don’t mind using this container.

I want to start adding other services to their own containers (git for example) and was considering using a tiny base image like busybox or alpinebox for these containers to keep image size down.

  • docker-compose: connection refused between containers, but service accessible from host
  • Cannot install Python Package with docker-compose
  • Forward local SSH credentials to Docker container inside Vagrant VM
  • What is the difference between docker-compose up and docker-compose start?
  • Error when installing docker-compose using ansible-playbook
  • Marathon command run docker-compose up error
  • That said, I have read that using the same base image as other containers only gives you the ‘penalty’ of the one time image download of the base OS (debian jessie) which is then cached – while using tiny OSes in other containers will download those OSes on top of the base OS.

    What is the best practice in this case? Should I use the same base image (debian jessie) for all the containers in this case?

  • docker run registry error 301 response missing Location header
  • Docker Wordpress timeout limit error db connection
  • Docker: Why does my home directory disappear after the build?
  • How to run Apache Spark 2.1 Driver Program in docker container with bridge mode
  • Can Docker help build executable that work in different platform
  • Docker remote API not accessible
  • One Solution collect form web for “Different images in containers”

    You may want to create a base image from scratch. Create a base image from scratch.

    From docker documentation

    You can use Docker’s reserved, minimal image, scratch, as a starting point for building containers. Using the scratch “image” signals to the build process that you want the next command in the Dockerfile to be the first filesystem layer in your image.

    While scratch appears in Docker’s repository on the hub, you can’t pull it, run it, or tag any image with the name scratch. Instead, you can refer to it in your Dockerfile. For example, to create a minimal container using scratch:

    This example creates the hello-world image used in the tutorials. If you want to test it out, you can clone the image repo

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