opened image

    A Docker app makes it easy to run/process manage sites/applications in isolated areas/containers.

    In containers, it is possible to run applications with resources isolated from the common system. Docker is very similar to a virtual machine like VirtualBox, but much more portable and resource efficient.

    OS packages need to be updated before installing Docker.

    yum check-update

    Download the required package and install:




    curl -fsSL | sh


    Check the Docker version:





    docker --version


    Let's check the status of Docker:





    systemctl status docker


    If it does not start, then run:





    systemctl start docker


    And add to autorun.





    systemctl enable docker


    In order to test in real conditions whether it is possible to access from Docker Hub and download a test container, run the following command:





    docker run hello world


    If Docker is working properly, you should be able to observe this output:

    The docker command is only run as root by default, or as a user in the docker group (the group is created automatically when docker is installed).
    Therefore, if you run the docker command without superuser (root) rights, you will get an error.

    In order not to use the sudo prefix each time, let's add the username from which we "sit" the docker group.





    sudo usermod -aG docker $(whoami)


    Apply the added rule without restarting the server:





    sudo usermod -aG docker username


    Where: username - the user in which you work. Enter the password on behalf of this user.

    Now we can enter the docker command without root privileges.

    To view all active/running containers, use the following command line:





    docker ps


    As you can see, no container is running. But we just downloaded and ran the hello-word test container! This container is no longer running, but still present in our system.

    To see it, use the following command line:





    docker ps -a


    As you can see, our hello-word container is loaded but not started.

    And so, in this article, we looked at how easy it is to install Docker and run a test container.

    You can learn how to install the services you need in Docker containers from the following articles.