Loading...
 

DockerInstallCentOS

How To Install and Use Docker on CentOS 7

 

Introduction


Docker is an application that makes it simple and easy to run application processes in a container, which are like virtual machines, only more portable, more resource-friendly, and more dependent on the host operating system. For a detailed introduction to the different components of a Docker container, check out The Docker Ecosystem: An Introduction to Common Components.

There are two methods for installing Docker on CentOS 7. One method involves installing it on an existing installation of the operating system. The other involves spinning up a server with a tool called Docker Machine that auto-installs Docker on it.

In this tutorial, you'll learn how to install and use it on an existing installation of CentOS 7.

Prerequisites

64-bit CentOS 7 Droplet
Non-root user with sudo privileges. A CentOS 7 server set up using Initial Setup Guide for CentOS 7 explains how to set this up.
Note: Docker requires a 64-bit version of CentOS 7 as well as a kernel version equal to or greater than 3.10. The default 64-bit CentOS 7 Droplet meets these requirements.

All the commands in this tutorial should be run as a non-root user. If root access is required for the command, it will be preceded by sudo. Initial Setup Guide for CentOS 7 explains how to add users and give them sudo access.

Step 1 — Installing Docker

The Docker installation package available in the official CentOS 7 repository may not be the latest version. To get the latest and greatest version, install Docker from the official Docker repository. This section shows you how to do just that.

But first, let's update the package database:

yum check-update

Update apps:

yum -y update

Uninstall old versions:

yum remove docker \
                  docker-common \
                  container-selinux \
                  docker-selinux \
                  docker-engine

Install required packages:

yum install -y yum-utils device-mapper-persistent-data lvm2

Use the following command to set up the stable repository:

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

Install the latest version of Docker:

sudo yum install docker-ce

After installation has completed, start the Docker daemon:

service docker start

Verify that it's running:

service docker status

Lastly, make sure it starts at every server reboot:

systemctl enable docker

Step 2 — Installing Git


Install the latest git package available in CentOS's repositories:

sudo yum install git

To double-check that it is working correctly, try running Git's built-in version check:

git --version

 

Step 3 — Installing docker-compose

Download Compose version 1.13.0:

curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

Then you can install Docker Compose:

chmod +x /usr/local/bin/docker-compose

Test the installation:

docker-compose version

Step 4 — Config Git


Setup machine user name:

git config --global user.name "Ben Ethington"

Setup machine user email:

git config --global user.email bethington at iccu.com

Setup machine user name:

git config --global core.editor nano

Get new ssh key:

ssh-keygen -t rsa -b 4096 -C "bethington@iccu.com"

Step 5 — Pull docker-compose.yml from Git


Clone ICCU-Innovations/shamrock_docker:

git clone git at github.com:ICCU-Innovations/shamrock_docker.git

Setup machine user email:

cd shamrock_docker

Setup machine user name:

docker-compose -f docker-compose.yml -f docker-compose.test.yml up

Setup machine user email:

touch shamrock.sh

Name

nano shamrock.sh 

Name

 #!/bin/bash

git clone git at github.com:ICCU-Innovations/shamrock_api.git shamrock_api
git clone git at github.com:ICCU-Innovations/shamrock_web.git shamrock_web
git clone git at github.com:ICCU-Innovations/shamrock_docker.git

cd shamrock_docker

docker-compose docker-compose.test.yml up
cd ..

Name

chmod +x shamrock.sh