In my previous post I have shared information about docker architecture and components with reference to Docker Documentation and Training Videos. Now time to start playing with docker, this is the First Learning Part will cover basic requirements for install Docker, how to install and some useful Linux commands, which you should aware while using Docker.
Let me share about my Lab, where I learns Docker. I using a nested setup of vSphere 6.5 with Centos 7 Virtual Machines to Learn Docker.
|vSphere 6.5||Cent OS 7 64 Bit||Docker CE ( Community Edition)|
Requirement to Run Docker CE (Community Edition)
- Maintained CentOS 7 64 Bit
- The centos-extrasrepository must be enabled.
Note: – This is enabled by default and incase it is disabled you have to re-enable it,
Refer: – Cent OS Wiki
- The overlay2storage driver is recommended.
Options to Install Docker
You can install Docker CE in three ways
- Set up Docker’s repositories and install from them it is will be easy for you to perform installation and upgrade tasks. This is the recommended approach by Docker, we proceed this option, and it need access to internet.
- Download the RPM package, install it manually, and manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.
Refer – Docker Docs to Understand this
- Automated convenience scripts to install Docker used in testing and development environments
Refer – Docker Docs to Understand this
To install the Docker CE , First we need to set up the Docker repository using YUM and then will perform installation of Docker from the repository .And if you have experience on the Linux then it will be very easy
Setting up the Repository
Login to your Cent OS through console or a putty session .
- Verify your Operating system details where you are going to setting up the repository and install Docker
Follow the basic command shown in the image to check Operating System , Kernel and Flavor of Linux you are using
command uname we can use to view the system information
If you want to know more about uname command use uname –help
- Install required packages for setting up the repository
yum-utils provides the yum-config-manager utility , device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver
$ sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2Set up the stable repository using below commands , Always need the stable repository, even if you want to install builds from edge or test repositories as well.
$ sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repoEnable the edge and test repositories, it is optional.
These repositories are included in the docker-ce.repo file but they are disabled by default and you can enable them alongside the stable repository using below commands
$ sudo yum-config-manager --enable docker-ce-edge
$ sudo yum-config-manager --enable docker-ce-test
You can disable the edge or test repository by running the yum-config-manager command with the –disable flag. To re-enable it, use the –enable flag.
To disables the edge repository follow below command
$ sudo yum-config-manager --disable docker-ce-edge
Note: Starting with Docker 17.06, stable releases are also pushed to the edge and testrepositories.
More about Repo
docker-ce.repo is located in /etc/yum.repos.d/ , you may view configuration of the file by using less , more or cat command
$ less /etc/yum.repos.d/docker-ce.repo
If there is no enabled line in this configuration file that means the repo is enabled , Image has taken before enabling the enabling edg repository
Also you can check the enabled repo’s by using below command
$ yum repolist enabled
This Image show the available repo before enabling edge and test repository
$ yum repolist enabled
This Image show the available repo after enabling edge and test repository
Now we are almost near to docker , let’s install docker and understand some basic commands required for a beginners
Install Docker CE
You have two options install the Docker
- Latest Version
- Install a specific version of Docker from repo
To install a specific version of Docker CE first you have to check the available versions in the repo, then select and install
List and sort the versions available in your repo. ( Command results by version number, highest to lowest)
$ yum list docker-ce --showduplicates | sort -r
The list returned depends on which repositories are enabled, and is specific to your version of CentOS (indicated by the
.el7 suffix in this example).
Install a specific version by its fully qualified package name, which is the package name (
docker-ce) plus the version string (2nd column) up to the first hyphen, separated by a hyphen (
-), for example,
$ sudo yum install docker-ce-<VERSION STRING>
Note:- I am not going perform this because my test setup i want to check with Latest version
Install the latest version of Docker CE , it is very simple just run the below command to get the latest version of docker 🙂
$ sudo yum install docker-ce
If prompted to accept the GPG key, verify that the fingerprint matches
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.
Got multiple Docker repositories?
If you have multiple Docker repositories enabled, installing or updating without specifying a version in the
yum updatecommand always installs the highest possible version, which may not be appropriate for your stability needs.
Now Docker is installed on your Linux Cent OS but it will not start automatically you have to start manually . Also a
docker group will be created , but no users are added to the group.
First verify the status of the docker service by running command
$ sudo systemctl status docker
Start the Docker using below command
$ sudo systemctl start docker
$ docker version
To check the docker version available on the system
Type just docker on the system it will list all the available management commands and other commands
Next Verify that
docker is installed correctly by running an image , question is if you are new to Docker how you will find available Images
As I mentioned above you can use the one of the command to check available images or from hub.docker.com
$ docker search image keyword
Run the an image , you can use your own required image or follow below to test
$ sudo docker run ubuntu
$ sudo docker image list – List running images
$ sudo docker rmi -f ubuntu – Remove an Image
Note :- Above image may show command without sudo because it is running with root login .
You can Refer Docker CLI to understand the commands can be used in Docker , Stay Tuned Next post will be with more Docker Commands for Initial Configuration .
Reference Installing Docker
Thank you for reading this post , Share the knowledge if you feel worth sharing it.