≡ 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
name=Docker Repository

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
 docker-engine x86_64 1.12.5-1.el7.centos dockerrepo 19 M
 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


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 !!

{ 0 comments… add one }

Leave a Comment