CentOS and RedHat have dropped support for Docker. To get the latest version, we have to manually install it.
First we have to install the latest version of containerd.io
:
dnf install https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.4.3-3.1.el8.x86_64.rpm
Add the docker repo
:
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Install docker
:
dnf install docker-ce -y
Get docker-compose
(as of this writing, 1.27.4
is the lastest version):
curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Make it executable:
chmod +x /usr/local/bin/docker-compose
Create an empty configuration file:
echo -e "{\n}" > /etc/docker/daemon.json
Note: On CentOS 8, the configuration file
/etc/docker/daemon.json
is not present by default. If present, it should have a validJSON
object. Thedockerd daemon
will print an error if the config file is blank.
Start and enable docker
:
systemctl start docker
systemctl enable docker
Then run one the following commands to make sure that the client can communicate with the daemon:
docker -v # prints the version of docker
docker version # prints the version of all the docker components
docker system info # prints all of the above, host info, and default configuration
Tips: To get the latest version of containerd.io
and docker-compose
#!/bin/bash
echo "Installing => containerd.io"
dnf install https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.4.3-3.1.el8.x86_64.rpm
echo "Adding the Docker repo"
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
echo "Installing => Docker Community Edition"
sleep 1
dnf install docker-ce -y
echo "Getting => Docker-Compose"
curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
{
if [ ! -s /etc/docker/daemon.json]; then
echo -e "{\n}" > /etc/docker/daemon.json
echo "Configuration file is created."
echo "It's empty by default."
sleep 2
fi
}
systemctl start docker
systemctl enable docker
clear
pgrep docker > /dev/null
if [ $? -eq 0 ]
then
echo "Docker is up and running."
docker -v
else
echo "Something is wrong!"
echo "Run: systemctl status docker"
fi