≡ Menu

How to install Docker on Linux?

  •  
  •  
  •  

Are your ready to taste the awesome power of Docker? I hope you are. Because once you get your feet wet in Docker, you will be unstoppable :-). In this blog post, I want to quickly show you how you can install Docker on RedHat Enterprise Linux. The procedure should be similar in other flavors.

  1. First, login as root into your system. If you don’t have root access, you should at least have sudo access to root.
  2. Create a docker repository file as follows
    • Use your favorite text editor to create a file named /etc/yum.repos.d/docker.repo
    • Add the following contents
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

3. Fire up the yum command as follows

yum install docker-engine -y

# yum install docker-engine
Loaded plugins: langpacks, package_upload, product-id, search-disabled-repos, subscription-manager
dockerrepo | 2.9 kB 00:00:00
rhel-7-server-optional-rpms | 1.8 kB 00:00:00
rhel-7-server-rpms | 2.0 kB 00:00:00
rhel-7-server-satellite-tools-6.1-rpms | 2.1 kB 00:00:00
dockerrepo/primary_db | 25 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:1.12.5-1.el7.centos will be installed
--> Processing Dependency: docker-engine-selinux >= 1.12.5-1.el7.centos for package: docker-engine-1.12.5-1.el7.centos.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-engine-1.12.5-1.el7.centos.x86_64
--> Processing Dependency: libltdl.so.7()(64bit) for package: docker-engine-1.12.5-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-engine-selinux.noarch 0:1.12.5-1.el7.centos will be installed
---> Package libseccomp.x86_64 0:2.2.1-1.el7 will be installed
---> Package libtool-ltdl.x86_64 0:2.4.2-21.el7_2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package Arch Version Repository Size
======================================================================================================================================================
Installing:
 docker-engine x86_64 1.12.5-1.el7.centos dockerrepo 19 M
...
...
Installed:
 docker-engine.x86_64 0:1.12.5-1.el7.centos

Dependency Installed:
 docker-engine-selinux.noarch 0:1.12.5-1.el7.centos libseccomp.x86_64 0:2.2.1-1.el7 libtool-ltdl.x86_64 0:2.4.2-21.el7_2

Complete!

4. Enable docker to run upon restart

# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

5. Start docker

# systemctl start docker

6. Check to make sure it is ineeded running

# systemctl status docker
● docker.service - Docker Application Container Engine
 Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
 Active: active (running)

...

7. Run the following command to check the version

# docker --version
Docker version 1.12.5, build 7392c3b

8. That’s it. You have the whole world of docker in your hands now. For example, if I need tomcat installed, all it takes is one command

# docker run -it --rm -p 8888:8080 tomcat
Unable to find image 'tomcat:latest' locally
latest: Pulling from library/tomcat

75a822cd7888: Pull complete
57de64c72267: Pull complete
cd1fc1696ecd: Pull complete
08fa5cecedd8: Pull complete
14e150de9a63: Pull complete
8a593a8d0d17: Pull complete

...

...

INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1181 ms

You can access your tomcat install by going to http://localhost:8888. Note that since there is no webapps installed, there will be nothing running at this point.

Go to hub.docker.com to download from the thousands of prebuilt docker images.

Enjoy !!


  •  
  •  
  •  
{ 4 comments… add one }
  • soubhik August 15, 2018, 2:28 pm

    Hi Karun, I came across your blog recently while searching for material on Docker and it helped me to get a good idea about it. Thanks for writing and sharing such a nice article.

  • Pramod October 16, 2019, 4:52 pm

    Thanks for putting it together. But I am getting the following error while following the steps as you mentioned. I tried to download the the RPM for docker-engine-selinux and then policycoreutils-python, but it shows another huge set of dependencies for policycoreutils-python. Please suggest. I am using EL v7 (3.10.0-1062.1.2.el7.x86_64).

    Error: Package: docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch (dockerrepo)
    Requires: policycoreutils-python
    You could try using –skip-broken to work around the problem
    You could try running: rpm -Va –nofiles –nodigest

  • Subrat Shaw December 27, 2019, 5:16 pm

    Thanks for providing the info and document

Leave a Comment