Creating CentOS docker containers

I have found plenty of instructions for building CentOS based containers, but the instructions I’ve come across only show you how to build a CentOS container with the same version of the OS as the host system. I am currently running CentOS 7, but I need a CentOS 6.5 container. Is it possible to install a different version of the OS, or even a different OS altogether, into a container using Docker hosted on CentOS 7? I am working with Docker on a private network, so I cannot access publically available container repositories.

Hi,

Yes, you can run containers based on any linux distribution. The only thing you need to do is to pull the corresponding Docker image from the Docker hub.

To get a CentOS 6.5 image on your Docker host running CentOS 7 (or any other docker host) you can execute the following command.

docker pull centos:6.5

Now as you don’t have access to public container repositories, you will have to get the docker image as a tarball from any docker host which has access to Docker Hub.

The steps are as follows.
First from a Docker host that has access to internet do the following steps.

docker pull centos:6.5
docker save -o centos-6.5.tar centos:6.5  #this will save the image to a tar file name centos-6.5.tar

Now bring the centos-6.5.tar to your machine and load it to docker.

docker load -i centos-6.5.tar

Regards