Troubleshooting Docker
上QQ阅读APP看书,第一时间看更新

Deploy CentOS VM on AWS to run Docker containers

We are using AWS as an environment to showcase Docker installation from a convenience perspective. If an OS needs to be tested for support of its Docker version, AWS is the easiest and quickest way to deploy and test it.

If you are not using AWS as an environment, feel free to skip the steps involving spinning a VM on AWS.

In this section, we'll take a look at deploying CentOS VM on AWS to get the environment up and running fast and deploy Docker containers. CentOS is similar to Red Hat's distribution and uses the same packaging tools like YUM. We will use CentOS 7.x, on which Docker is officially supported:

First, let's launch a CentOS-based VM on AWS:

We are launching with a 1-Click Launch and pre-existing keypair. SSH is enabled by default:

Once the instance is up, get the public IP address from the AWS EC2 console.

SSH into the instance and follow the following steps for installation:

$ ssh -i "ubuntu-1404-1.pem" centos@54.238.154.134

Checking kernel version

The kernel version of the Linux OS can be checked with the following command:

$ uname -r

The output, in our case, is kernel version 3.10.x, which will work fine:

3.10.0-327.10.1.el7.x86_64

Note how similar it is to the Red Hat kernel version 3.10.0-327.el7.x86_64.

Updating the YUM packages

The YUM packages and repository can be updated, as shown here:

$ sudo yum update Output listing is given, make sure it shows complete at the end Loaded plugins: fastestmirror base | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 (1/4): base/7/x86_64/group_gz | 155 kB 00:00 (2/4): extras/7/x86_64/primary_db | 117 kB 00:00 (3/4): updates/7/x86_64/primary_db | 4.1 MB 00:00 (4/4): base/7/x86_64/primary_db | 5.3 MB 00:00 Determining fastest mirrors * base: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp Resolving Dependencies --> Running transaction check ---> Package bind-libs-lite.x86_64 32:9.9.4-29.el7_2.2 will be updated ---> Package bind-libs-lite.x86_64 32:9.9.4-29.el7_2.3 will be an update ---> Package bind-license.noarch 32:9.9.4-29.el7_2.2 will be updated ---> Package bind-license.noarch 32:9.9.4-29.el7_2.3 will be an update .... teamd.x86_64 0:1.17-6.el7_2 tuned.noarch 0:2.5.1-4.el7_2.3 tzdata.noarch 0:2016c-1.el7 util-linux.x86_64 0:2.23.2-26.el7_2.2 Complete!

Adding the YUM repository

Let's add the Docker repository to the YUM repository:

$ sudo tee /etc/yum.repos.d/docker.repo <<-EOF [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7 enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF

Installing the Docker package

The following command can be used to install Docker Engine using the YUM repository:

$ sudo yum install docker-engine

Starting the Docker service

The Docker service can be started in the following way:

$ sudo service docker start 
Redirecting to /bin/systemctl start docker.service

Testing the Docker installation

$ sudo docker ps -a

Output:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 

Check the Docker version to make sure it is the latest:

$ docker --version
Docker version 1.11.0, build 4dc5990

Checking the installation parameters

Let's run Docker information to see the default installation parameters:

$ sudo docker info

The output is listed here; note that the Storage Driver is devicemapper:

Server Version: 1.11.0 Storage Driver: devicemapper ... Kernel Version: 3.10.0-327.10.1.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 991.7 MiB Name: ip-172-30-0-236 ID: EG2K:G4ZR:YHJ4:APYL:WV3S:EODM:MHKT:UVPE:A2BE:NONM:A7E2:LNED Docker Root Dir: /var/lib/docker Registry: https://index.docker.io/v1/