Installing Docker on CentOS 7 in Four Simple Steps

June 3, 2015 / FAQs
Installing_Docker

Are you new to Docker? Docker is an open-source, container-based software framework for creating and managing Linux containers (LXC) in an easy manner. What are containers? Containers are lightweight, encapsulated and portable application modules.

When talking about benefits, Docker helps the coders and system admin with their application development in a container and further can be scaled up to 1000 nodes.

In this post, we will be discussing the basic installation of Docker in CentOS 7. x –

  1. Installing Docker
    There is a need to update your packages:

    yum –y update

    Now, it’s time to install Docker by installing the docker-io package.

    yum –y install docker docker-registry

  2. Starting Docker and Ensuring Docker Starts on Boot
    Set the Docker service to start at boot:

    systemct1 enable docker.service

    Then start the Docker service:

    systemct1 start docker.service

    You can verify your work by checking the status of Docker:

    systemct1 status docker.service

  3. Downloading a Docker Container
    Let’s start using Docker. Download the Centos Docker image:

    docker pull centos

  4. Running a Docker Container
    Now, it’s time to set up a basic centos container using a bash shell wherein we have to run only one command, docker run will run a command in a new container, -I attaches stdin and stdout, -t allocates a tty.

    docker run –i –t centos /bin/bash

    That’s done! This means you are now using a bash shell inside of a centos docker container.

    If you want to disconnect or detach from the shell without existing use the escape sequence

    Ctrl-p + Ctrl-q

    You will find several community containers already available and can be found through research. For example, the command below is for searching for the keyword centos –

    docker search centos 

     So, you can now install Docker on CentOS 7.x with these simple steps.