For building the official CentOS docker image, we would need to download the necessary files from the following link:
CentOS 6 Official docker image build files
The following are the necessary files
- File named dockerfile
- The compressed CentOS6 docker file
Create a directory for downloading the files.
mkdir CentOS-Docker cd CentOS-Docker
Now download the files into this directory. The files can be downloaded using the following commands
wget https://github.com/CentOS/sig-cloud-instance-images/raw/311d80f2e558eba3a6ea88c387714ae2e4175702/docker/Dockerfile wget https://github.com/CentOS/sig-cloud-instance-images/blob/311d80f2e558eba3a6ea88c387714ae2e4175702/docker/centos-6-20150615_2019-docker.tar.xz?raw=true mv centos-6-20150615_2019-docker.tar.xz\?raw\=true centos-6-20150615_2019-docker.tar.xz
Once these files are downloaded, run the following command to build the docker image
docker build .
The output of the command will be like this.
Sending build context to Docker daemon 98.86 MB Sending build context to Docker daemon Step 0 : FROM scratch ---> Step 1 : MAINTAINER The CentOS Project - ami_creator ---> Using cache ---> f1b10cd84249 Step 2 : ADD centos-6-20150615_2019-docker.tar.xz / ---> c1f42ce4ff39 Removing intermediate container 2a4b49b94ee1 Step 3 : CMD /bin/bash ---> Running in 7b76234dc0e4 ---> 9891dba63992 Removing intermediate container 7b76234dc0e4 Successfully built 9891dba63992
Now run the container from this image built, by using the following command
docker run docker -it 9891dba63992 /bin/bash