透過docker建置測試環境一整個快速,這篇記錄如何安裝docker and docker compose on CentOS 7
透過docker我可以很快生出redis、kafka、zookeeper、sql server…等application,
也可以針對這些application,更進一步預先模擬架構scale out(如cluster,load balance..等),
我只能說用過docker才知道docker的好,但我個人還是會針對一些重要應用程式(如kafka,redis,zookeeper..等)深入探索,
因為我遇過不少工程師都說會某某某application,但在更進一步交談後,
我發現都只是過水而已,因為都只是透過docker-compose來建立後就沒下文了,
簡單說就是根本沒有實務經驗。
@Install Docker CE
Sudo yum -y install docker docker-registry
Sudo yum install -y yum-utils device-mapper-persistent-data lvm2 # install the Docker CE dependencies.
Docker provides a repository where you can fetch the stable Docker CE version.
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo #add docker repository
sudo yum install -y docker-ce
docker –version #check docker version
note: yum erase docker-engine-selinux to fix Install Instructions Causing Conflicts
sudo systemctl enable docker.service
sudo systemctl start docker.service
sudo systemctl status docker.service
usermod -aG docker Jenkins #order to work normal for CI and CD.
@Installing Docker Compose
sudo yum -y install epel-release #install the EPEL repository
sudo yum -y install python-pip #install python-pip
sudo pip install docker-compose #install docker-compose
sudo yum -y upgrade python*
docker-compose -v #check Docker Compose version
@Change default image and container location
Docker info
預設loaction:/var/lib/docker
Sudo systemctl stop docker #關閉docker service
vi /lib/systemd/system/docker.service #編輯docker service config
from
ExecStart=/usr/bin/dockerdsyst
to
ExecStart=/usr/bin/dockerd --graph=/extend/datas --storage-driver=devicemapper
sudo systemctl daemon-reload
sudo systemctl start docker
docker info #check docker root dir if it’s as expect
參考
Docker Compose: How To Install on CentOS 7
How To Install and Use Docker Compose on CentOS 7
Change default Image and Container location in Docker [CentOS 7]
How to move docker's default /var/lib/docker to another directory on Ubuntu/Debian Linux
How to change Docker Image default Installation Directory
Use GParted to increase disk size of a Linux native partition