CentOS Installation Docker

Source: Internet
Author: User
Tags truncated docker run
Prerequisites for Linux installation Docker:Must be a 64-bit CPU-architected computer, Docker currently does not support 32-bit CPUs, running Linux3.8 or later kernel, CentOS kernel must be no less than 3.10; the kernel has to support an appropriate storage driver, which can be device Manager, Aufs, VFS, Btrfs, and one of the default driver device mapper; The kernel must support and open the Cgroup and namespace namespace features. Check Prerequisites

Kernel

Check kernel version information with the uname command.

Check to see if the memory driver exists, that is, check device Mapper

Version Description

Docker from the 1.13.x version, the version is divided into Enterprise version EE and Community Edition CE, the version number is also changed to the timeline to publish, such as 17.03 is March 2017, a bit similar to the version of Ubuntu release mode.

Docker engine changed to Docker CE (Community Edition)
It contains CLI clients, background processes/services, and APIs. The user gets the same way as before.

The CE version is divided into two kinds of stable and edge publishing methods. Stable version is the quarterly release way, such as 17.03, 17.06, 17.09 Edge version is the month release way, such as 17.03, 17.04 ... The Edge version is released monthly, providing one months support. The stable version is released quarterly and offers 4 months of support.

Change Docker Data Center to Docker EE (Enterprise Edition)
The Enterprise Edition offers some additional fee-based services. Enterprise Version Description here

Normal learning and development personally think that CE is enough. Uninstall old version

The old version of Docker is called Docker or Docker-engine. If these are installed, uninstall them and the associated dependencies.

sudo yum remove docker \
                docker-common \
                docker-selinux \
                docker-engine
Install Docker CE

Docker CE can be installed in different ways according to need:

Set up the Docker repository and install it to facilitate installation and upgrade tasks. This is the recommended method.

Download the RPM package and manually install and manage the upgrade manually.

This is useful in situations such as installing Docker on a gap system that does not have access to the Internet.

In the test and development environment, use automated convenience scripts to install Docker. using repositories for installation

Installing repositories

Install the necessary packages. Yum-utils provides the Yum-config-manager utility, and Device-mapper-persistent-data and LVM2 require devicemapper storage drivers. This step in front of the check if passed, you can skip.

sudo yum install-y yum-utils \
  device-mapper-persistent-data \
  lvm2

Use the following command to set up a stable repository.

sudo yum-config-manager \
    --add-repo \
    Https://download.docker.com/linux/centos/docker-ce.repo

Optional: Enable Test and Edge. These repositories are contained in the Docker.repo file above, but are disabled by default. You can enable them with the stable version library.

sudo yum-config-manager--enable docker-ce-edge

sudo yum-config-manager--enable docker-ce-test

You can disable the edge or test library by running the Yum-config-manager command with the--disable flag. To re-enable it, use the--enable flag. The following command disables the Edge repository.

sudo yum-config-manager--disable Docker-ce-edge

Starting with Docker 17.06, the stable version was also pushed to the edge and test repository to install the latest version of Docker CE, or go to the next installation specific version.

sudo yum install Docker-ce

Warning: If multiple Docker repositories are enabled, a version that is not installed or updated in the Yum install or Yum Update command will always install the highest possible version, which may not be appropriate for your stability needs.

If this is the first time you have installed a package from a recently added repository, you will be prompted to accept the GPG key and display the thumbprint of the key. Verify that the fingerprint is correct, and if so, accept the key. Fingerprints should match.

060A 61c5 1b55 8a7f 742B 77AA c52f eb6b 621E 9f35

Docker is installed but not started. The Docker group was created, but no users were added to the group. On a production system, you should install a specific version of Docker CE instead of always using the latest version. Lists the available versions. This example uses the sort-r command to sort the results, with the version number from highest to lowest and truncated.

Yum List Docker-ce--showduplicates | Sort-r

docker-ce.x86_64            17.09.ce-1.el7.centos             docker-ce-stable

The contents of the list depend on which repositories are enabled and will be specific to your version of CentOS (shown in this example by the version of the. el7 suffix). Select a specific version to install. The second column is the version string. You can use the entire version string, but you need to include at least the first hyphen. The third column is the repository name, which indicates the package's repository and its stability level. To install a specific version, attach the version string to the package name and separate it with a hyphen (-).

The version string is the package name plus the version until the first hyphen. In the example above, the fully qualified package name is DOCKER-CE-17.09.CE.

sudo yum install <FULLY-QUALIFIED-PACKAGE-NAME>

3. Start Docker

sudo systemctl start Docker

4. Verify that the Docker is properly installed by running the Hello-world image.

sudo Docker run Hello-world

This command downloads the Hello-world image and runs it in the container. When the container is running, it prints an informational message and exits.

Docker CE has been installed and running. You need to use sudo to run the Docker command. After continuing with the Linux installation, allow unprivileged users to run the Docker command and other optional configuration steps. installing from the wrapper

If you cannot use the Docker repository to install Docker, you can download your version of the. rpm file and install it manually. Each time you want to upgrade Docker, you need to download a new file.

1 Access https://download.docker.com/linux/centos/7/x86_64/stable/Packages/and download the. rpm file for the Docker version you want to install.

To install the Edge package, please change the stable in the above URL to edge.

2. Install Docker CE, change the path below to download the Docker package path for you.

sudo yum install/path/to/package.rpm

Docker is installed but not started. The Docker group was created, but no users were added to the group.

3. Start Docker

sudo systemctl start Docker

4. Verify that the Docker is properly installed by running the Hello-world image.

sudo Docker run Hello-world

This command downloads the Hello-world image and runs it in the container. When the container is running, it prints an informational message and exits.

Docker CE has been installed and running. You need to use sudo to run the Docker command. Continue with the post-installation steps of Linux to allow unprivileged users to run the Docker command and other optional configuration steps. Upgrade Docker

To upgrade Docker CE, download the newer package file and repeat the installation process, using YUM-Y upgrade instead of Yum-y install, and point to the new file. installing with a handy script

The Docker provides handy scripting on get.docker.com and test.docker.com for Docker CE stability and beta release, fast, non-interactive installation into the development environment. The source code for the script is located in the Docker-install repository. Using these scripts in a production environment is not recommended, and you should understand the potential risks before using them: The script requires root or sudo permissions to run. Therefore, you should carefully review and audit the script before running the script. These scripts try to detect your Linux distributions and versions, and configure your package management system for you. In addition, the script does not allow you to customize any installation parameters. This can lead to unsupported configurations, either from the Docker perspective or from your own organization's guidelines and standards. The script installs all the dependencies and recommendations of the package manager without requiring confirmation. This may install a large number of packages, depending on the current configuration of the host. If Docker is already installed on the host using a different mechanism, do not use the convenience script.

This example uses the script on get.docker.com to install the latest Docker CE version on Linux. To install the latest test version, use test.docker.com instead. In each of the following commands, replace each occurrence of get with test.

Warning: Always check for scripts downloaded from the Internet before running locally.

Curl-fssl get.docker.com-o get-docker.sh
 sudo sh get-docker.sh

<output truncated>

If you would like T O use Docker as a non-root user, your should now consider
adding your user to the ' Docker ' group with something like:
  sudo Usermod-ag Docker Your-user Remember that you'll have to log out and then in the to

take effect!

Warning:adding a user to the "Docker" group would grant the ability to run
         containers which can is used to obtain root Privileges on the
         Docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface for more
         information.

Docker CE has been installed. It starts automatically on a deb-based distribution. In an RPM-based release, you need to manually start it with the appropriate SYSTEMCTL or service command. The message shows that the Docker command cannot be run by default by a non-root user. upgrade with convenient scripting

If you install Docker using convenient scripting, you should upgrade Docker directly using Package Manager. It does not do any good to rerun the handy script, which can cause problems if you try to add a repository that has already been added to the host. Uninstall Docker CE Uninstall Docker package

sudo yum remove docker-ce
Figure mages, containers, volumes, or custom configuration files on the host are not automatically deleted. Delete all mages, containers, volumes:
sudo rm-rf/var/lib/docker

You must manually delete any of the definition configuration files.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.