CentOS7_Install_Docker_and_docker-compose
Install Docker
# Install Docker CE
## Set up the repository
### Install required packages.
yum install yum-utils device-mapper-persistent-data lvm2
### Add Docker repository.
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
yum update && yum install docker-ce-18.06.2.ce
# If you are going to use local rpm to install Docker, follow steps below:
# First copy docker rpms from 10.20.0.198:/root/rpms/docker
# mkdir -pv /root/rpms/docker && \
# scp -r root@10.20.0.198:/root/rpms/docker /root/rpms/docker && \
# cd /root/rpms/docker && \
# yum localinstall ./*.rpm
# Add your user to the docker group with the following command.
usermod -aG docker $(whoami)
## Create /etc/docker directory.
mkdir -pv /etc/docker
# Setup daemon.
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "20m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
# Don't forget to set SELinux to permissive:
# Set SELinux in permissive mode (effectively disabling it)
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
# Set Docker to start automatically at boot time:
systemctl enable docker.service
# Restart Docker
systemctl daemon-reload
systemctl restart docker
# Check docker daemon info
docker info
# Check if docker runs normally
docker run --rm --name=hello-world hello-world
Install docker-compose
Run this command to download the current stable release of Docker Compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
Note: If the command docker-compose fails after installation, check your path.
You can also create a symbolic link to /usr/bin or any other directory in your path.For example:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Test the installation.
$ docker-compose --version docker-compose version 1.24.1, build 1110ad01