0

Docker on CentOS/RHEL7 101 Part 1

My journey with Docker.

Installing Docker on CentOS/RHEL7

$ sudo yum install docker
$ sudo systemctl start docker
$ sudo systemctl enable docker

NOTE: if you are using firewalld make sure that firewalld is started before Docker. Also if firewalld is restarted please make sure to restart Docker afterwards.

Now that Docker is installed lets pull a image and play with it a bit.

$ sudo docker pull centos # pulls the latest centos7 container
Trying to pull repository docker.io/centos ...
fd44297e2ddb: Download complete
6941bfcbbfca: Download complete
41459f052977: Download complete
Status: Image is up to date for docker.io/centos:latest

$ sudo docker images # shows the docker images on the system
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker.io/centos 7 fd44297e2ddb 17 hours ago 215.7 MB
docker.io/centos centos7 fd44297e2ddb 17 hours ago 215.7 MB
docker.io/centos latest fd44297e2ddb 17 hours ago 215.7 MB

$ sudo docker run centos:latest cat /etc/*-release # lets view the release files inside of the container
CentOS Linux release 7.1.1503 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.1.1503 (Core)
CentOS Linux release 7.1.1503 (Core)

$ sudo docker run -i -t centos /bin/bash # lets run the bash prompt from the container
[root@e420f506ff4a /]# exit
exit

while in the /bin/bash you can make changes to the container environment.
Also if you look at the IP configuration of the host you will see the docker0 interface which acts as a bridge into the containers.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.