Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Installing Docker and Docker Compose on CentOS 7

Tech 1

Overview

This section outlines the process of installing Docker on CentOS 7, covering both online and offline installation methods. Only CentOS 7 and later versions with kernel 3.10 or higher are supported.

Online Installation of Docker

  1. Check the system version:

    cat /etc/redhat-release
    
  2. Install required dependencies:

    yum install -y yum-utils device-mapper-persistent-data lvm2
    
  3. Add the Docker repository:

    yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    
  4. Update package cache:

    yum makecache fast
    
  5. Install Docker Community Edition:

    yum -y install docker-ce
    
  6. Start the Docker service:

    systemctl start docker
    
  7. Verify the installation:

    docker version
    
  8. Download and install Docker Compose:

    curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
    
  9. Set execute permissions:

    chmod +x /usr/local/bin/docker-compose
    
  10. Confirm Docker Compose installation:

    docker-compose version
    
  11. Enable Docker to start at boot:

    systemctl enable docker
    

Offline Instalaltion of Docker

  1. Obtain the offline installation package, typically named centos-local.tgz (contact for access).

  2. Upload the package to the root directory of the server.

  3. Extract the archive:

    cd /root
    tar -xvzf centos-local.tgz
    
  4. Install createrepo:

    cd /root/docker-ce-local
    rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm
    
  5. Create a local repository configuration file:

    vi /etc/yum.repos.d/docker-ce-local.repo
    

    With the following content:

    [docker-ce-local]
    name=Local Yum
    baseurl=file:///root/docker-ce-local/
    gpgcheck=1
    gpgkey=file:///root/docker-ce-local/gpg
    enabled=1
    
  6. Generate repository metadata:

    createrepo /root/docker-ce-local
    yum makecache
    
  7. Install Docker CE without GPG verification:

    yum install docker-ce --nogpgcheck
    
  8. Start and verify Docker:

    systemctl start docker
    docker version
    
  9. Enable auto-start on boot:

    systemctl enable docker
    
  10. Copy Docker Compose binary:

    cp /root/docker-ce-local/docker-compose /usr/bin/
    
  11. Set execution rights:

    chmod +x /usr/bin/docker-compose
    
  12. Validate Docker Compose:

    docker-compose version
    
Tags: dockercentos

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.