How to install and use Docker on RHEL 7 or CentOS 7
Docker is a container virtualization technology that has gained widespread popularity in recent times; it offers a more efficient way to deploy the application. With Docker, the applications reside inside the container on top of the Linux operating system.
Docker uses Kernel features such as cgroups and namespace to allow an independent container to run on single os instance.
In this post, you will learn how to install Docker on CentOS 7 / RHEL 7.
First, install the required packages.
Docker runs only on 64-bit operating system.
[root@L1nxr00t ~]# yum -y install lvm2 device-mapper device-mapper-persistent-data device-mapper-event device-mapper-libs device-mapper-event-libs
The Docker Comunity package is now called “docker-ce“. Let’s add the CE repository for docker installation.
# wget https://download.docker.com/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
2. Install Docker.
[root@L1nxr00t ~]# yum install docker device-mapper-libs device-mapper-event-libs
3. Enable & Start docker service
[root@L1nxr00t ~]# systemctl enable docker
[root@L1nxr00t ~]# systemctl start docker
[root@L1nxr00t ~]# systemctl status docekr
4. Check for docker images.
[root@L1nxr00t ~]# docker images
5. Search into registry for images you required
[root@L1nxr00t ~]# docker search mysql
[root@L1nxr00t ~]# docker search centos
6. Download centos docker image.
[root@L1nxr00t ~]# docker pull docker.io/centos
7. Verify image is locally available
[root@L1nxr00t ~]# docker images
8. Create docker container by giving name “webserver”
[root@L1nxr00t ~]# docker run -itd --name webserver docker.io/centos
9. Check container is up & running
[root@L1nxr00t ~]# docker ps
10. Enter into container
[root@L1nxr00t ~]# docker attach web-server
11. Install apache inside container and verify.
[root@ffc410f6f0c1 ~]# yum install iproute -y
[root@ffc410f6f0c1 ~]# yum install httpd
[root@ffc410f6f0c1 ~]# httpd -k start
12. Install mysql inside container and verify.
[root@L1nxr00t ~] docker search mysql
[root@L1nxr00t ~] docker pull mysql
[root@L1nxr00t ~] docker run --name some-mysql -e
MYSQL_ROOT_PASSWORD=redhat -d mysql:mysql-demo
[root@L1nxr00t ~] docker exec -it some-mysql bash
By:- Mr.L1nx_r00t
No comments:
Post a Comment