Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (Twitter) Instagram
    TecAdmin
    You are at:Home»Docker»How to Install Docker on CentOS 7 & RHEL 7

    How to Install Docker on CentOS 7 & RHEL 7

    By RahulDecember 13, 20193 Mins Read

    Docker is container-based application framework, which wrap of a specific application with all its dependencies in a container. Docker containers can easily to ship to a remote location on start there without making entire application setup. This tutorial will help you to install and manage Docker on CentOS/RHEL 7/6 operating system.

    Step 1 – Verify Requirements

    For a standard installation, Docker required 64-bit operating system having Kernel >= 3.10 version. Older versions of Kernel have some missing requirements to run all features of Docker.

    uname -r
    
    3.19.0-49-generic
    

    Also install the following packages on your system.

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

    Step 2 – Add Docker Yum Repository

    Let’s add the official Docker yum repository on your system.

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

    Step 3 – Install Docker on CentOS 7

    After adding the yum repository to your CentOS system, update the yum cache by executing the following command.

    sudo yum makecache fast
    

    Now install docker community edition package to install docker on your system. This is installed many of required decencies on your system.

    sudo yum install docker-ce
    

    After successful installation of Docker engine, Let’s start the docker service.

    sudo systemctl start docker.service
    

    Then check the status of the Docker service.

    Install Docker on CentOS 7

    Docker has been installed and running on your system. You can visit our Docker tutorial section to work with Docker containers.

    How to Use Docker?

    Search Docker Images

    First of all search Docker container images from Docker hub. For example, below command will search all images with Ubuntu and list as output

    sudo docker search centos
    

    Download Docker Images

    Now download the Docker container with name Ubuntu on your local system using following commands.

    sudo docker pull ubuntu
    
    latest: Pulling from library/ubuntu
    
    fa5be2806d4c: Pull complete
    b4af4261cb15: Downloading [==>               ] 3.779 MB/70.55 MB
    5d358abc5d9c: Download complete
    2933d50b9f77: Download complete
    

    Now make sure that above images have been downloaded successfully on your system. Below command list all images.

    sudo docker images
    
    REPOSITORY  TAG            IMAGE ID            CREATED             VIRTUAL SIZE
    ubuntu      latest         36248ae4a9ac        2 days ago          188 MB
    centos      latest         2933d50b9f77        2 days ago          196.6 MB
    

    Launch New Container with Image

    Finally, launch a Docker container using the above-downloaded image on your system. Below command will start a new container and provide you access to that container with /bin/bash shell.

    docker run -i -t ubuntu /bin/bash
    

    To exit from docker container type CTRL + P + Q. This will leave container running in the background an provide you host system console. If you used exit command, it will stop the current container.

    After exiting from Docker container, execute below command to list all running containers.

    docker ps
    
    CONTAINER ID     IMAGE     COMMAND        CREATED        STATUS        PORTS    NAMES
    f2582758af13     ubuntu    "/bin/bash"    2 hours ago    Up 2 hours             first_ubuntu
    

    By default Above command will list only running containers. To list all containers (including stopped container) use the following command.

    docker ps -a
    

    Start/Stop/Attach Container

    You can start, stop or attach to any containers with following commands. To start container use following command.

    docker start CONTAINER_ID
    

    To stop container use following command.

    docker stop CONTAINER_ID
    

    To attach to currently running container use following command.

    docker attach CONTAINER_ID
    

    Container Docker Docker engine Docker install
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Setting Up Ubuntu Docker Container with SSH Access

    How to Deploy PHP, Apache, and MySQL with Docker Compose

    Setting Up Environment Variables in Docker: A Comprehensive Guide

    View 4 Comments

    4 Comments

    1. Pawan on May 27, 2019 11:56 am

      Great article, but step 2 is not correct.

      Please correct it as below

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

      Reply
      • Nguyễn Trọng Đạt on August 8, 2019 11:45 am

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

        Reply
    2. Leo Kennedy on February 1, 2019 4:46 pm

      Hello Rahul,

      I am currently running RHEL 7.6 fully yum updated as of 20190201. Will I be running into any difficult issues sitting at 7.6? It certainly sounds like I’ll be just fine, judging by this discussion and your direction.

      Would that be a fair assumption to make?

      Best regards,
      Leo

      Reply
    3. ram on January 31, 2019 12:07 pm

      issue in installing docker 17.06 version in centos6 .error came dependented files are missing

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Using .env File in FastAPI
    • Setting Up Email Notifications for Django Error Reporting
    • How to Enable Apache Rewrite (mod_rewrite) Module
    • What are Microservices?
    • Variable Expansion in ZSH
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.