Add Image to my Base Docker Image

I have a docker base image that runs CentOS 6.5. This image is saved on my computer. I could not find anything that talks about how to add more images into this base image. So for example I have this base image of CentOS6.5, I need too add postgresql 9.3, and php too this base image. Is there a way once you already have a base image made, to add more packages too that base image?

  • Running ejabberd inside docker container is causing PREVIOUS.LOG enoent crash
  • 'sbt ~run' shows that it's recompiling, but no changes visible
  • Exception when running Spark job server in spark standalone mode
  • How to know when composer install finishes in docker container
  • Upgrade docker-compose to version 3
  • /public/img/ folder not acceping new assets in Go-compiled web app
  • confused with CMD and ENTRYPOINT in dockerfile
  • Unable to use variable substitution in docker-compose
  • CentOS 6 Docker 1.7 with error “panic: runtime error: invalid memory address or nil pointer dereference”
  • Why can mysql CLI connect, but not WordPress?
  • Dockerfile: is it necessary to specify which user before perform a RUN?
  • How can we avoid generating cache on host system by Docker Container?
  • 2 Solutions collect form web for “Add Image to my Base Docker Image”

    That’s the whole purpose of the Docker file : build something on top of an image.

    1. Create your dockerfile
    2. Build the new image and tag it with docker build -t <tag> <path/to/build/context>
    3. Then if you want to share it, push it to your private registry or to the docker hub to make it world accessible (docker push <tag>).

    The build context of step 2 is the parent directory of your Dockerfile. For instance if you run the command in the directory where your dockerfile is it would be docker build -t <tag> ..

    You can use Dockerfiles and docker build to do this e.g.:

    FROM yourCentos
    MAINTAINER your name
    RUN yum install ...
    CMD ...

    And then docker build -t="myImage" . in the direcotry where you created the dockerfile.

    Or you can upgrade youe images via CLI (not the preferd way!!) and commit them.

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