DevOpsDockersHow to

How to Installing Docker CE via the Docker Repository

Installing Docker on a CentOS:

First, we will need to install some required packages. Open a terminal window and enter the following command:
# installing required packages
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2


This will make sure that we have both the yum-config-manager utility and the device
mapper storage driver installed on the system. It is illustrated in the following screenshot:


Note that your installation of CentOS 7 may already have these installed,
and in that case the yum install command will report that there is
nothing to do.

Next, we will set up the CentOS stable repository for Docker CE.
It is worth noting that you will still need to set up the stable repository even if you want to
install the edge releases.
Enter the following command to set up the stable repository:
# adding the docker-ce repo
sudo yum-config-manager \
–add-repo \

Optionally, if you want to use the edge release, you can enable it with the following
command:
# enable edge releases
sudo yum-config-manager –enable docker-ce-edge

you can disable access to the edge release with this command:
# disable edge releases
sudo yum-config-manager –disable docker-ce-edge
Now to install Docker CE. To do so, enter the following command:
# install docker
sudo yum -y install docker-ce

# validate install with version command
docker –version

The latest version of Docker CE:

validate install with version command

To start the docker deamon, need to issue the following command:

# start docker deamon
sudo systemctl start docker
Let’s issue the following command to run the hello-world container:
# run a test container
sudo docker run hello-world
If all is well, you will see something like the following:

Installing Docker on an Ubuntu:

Installing Docker CE via the Docker Repository
We need to set up the Docker repository first, and then we can do the installation, so let’s
take care of the repo now.
The first step will be to update the apt package index. Use the following command to do that:

# update apt-get libraries
sudo apt-get update
Now we need to install some supporting packages:
# install required packages
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \

software-properties-common
Next, we need to get the GPG key for Docker:
# get the GPG key for docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo apt-key add –

Installing Docker CE by running convenience scripts:

Another method of installing Docker is to use the convenience scripts provided by Docker. The scripts allow you to install either the latest edge version or the latest test version of Docker. It is not recommended that either of these is used in a production environment, however, they do serve a purpose for testing and developing the latest Docker versions. The scripts are somewhat limited in that they do not allow you to customize any options in the install. The same scripts can be used across a variety of Linux distributions as they determine the base distro you are running, and then do the install based on that determination. The process is simple. Use curl to pull down the desired script, and then use sudo to run the script. The commands to run the latest edge version are as follows.

Use the following command to install curl:

# install curl
sudo apt-get install curl

Now get the script and run the docker script to install:

# download and run the docker install script
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Executing the script will result in output that looks like the following:

The docker group has been created for you by the script. The Docker service has been started, and the workstation has been configured to run Docker on boot. So, once again, you are ready to start using Docker.

Post-install steps you might want to consider
All three of these install methods automatically create a docker group for you, but if you want to be able to run Docker commands without using root or sudo, you will want to add your user to the docker group.

Adding the current user to the docker group is easily accomplished with the following command:
# add the current user to the docker group
sudo usermod -aG docker $USER

Please Note: You will need to log out and log back in to update the group memberships on your account, but once you have done that, you should be all set to execute any Docker commands without using sudo.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

7bQDVn

Please type the text above:

Close
Close