github.com/akashshinde/docker@v1.9.1/docs/installation/centos.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Installation on CentOS"
     4  description = "Instructions for installing Docker on CentOS"
     5  keywords = ["Docker, Docker documentation, requirements, linux, centos, epel, docker.io,  docker-io"]
     6  [menu.main]
     7  parent = "smn_linux"
     8  weight=-4
     9  +++
    10  <![end-metadata]-->
    11  
    12  # CentOS
    13  
    14  Docker runs on CentOS 7.X. An installation on other binary compatible EL7
    15  distributions such as Scientific Linux might succeed, but Docker does not test
    16  or support Docker on these distributions.
    17  
    18  This page instructs you to install using Docker-managed release packages and
    19  installation mechanisms. Using these packages ensures you get the latest release
    20  of Docker. If you wish to install using CentOS-managed packages, consult your
    21  CentOS documentation.
    22  
    23  ## Prerequisites
    24  
    25  Docker requires a 64-bit installation regardless of your CentOS version. Also,
    26  your kernel must be 3.10 at minimum, which CentOS 7 runs.
    27  
    28  To check your current kernel version, open a terminal and use `uname -r` to
    29  display your kernel version:
    30  
    31      $ uname -r
    32      3.10.0-229.el7.x86_64
    33  
    34  Finally, is it recommended that you fully update your system. Please keep in
    35  mind that your system should be fully patched to fix any potential kernel bugs.
    36  Any reported kernel bugs may have already been fixed on the latest kernel
    37  packages.
    38  
    39  ## Install
    40  
    41  There are two ways to install Docker Engine.  You can install using the `yum`
    42  package manager. Or you can use `curl` with the  `get.docker.com` site. This
    43  second method runs an installation script which also installs via the `yum`
    44  package manager.
    45  
    46  ### Install with yum
    47  
    48  1. Log into your machine as a user with `sudo` or `root` privileges.
    49  
    50  2. Make sure your existing yum packages are up-to-date.
    51  
    52          $ sudo yum update
    53  
    54  3. Add the yum repo.
    55  
    56          $ cat >/etc/yum.repos.d/docker.repo <<-EOF
    57          [dockerrepo]
    58          name=Docker Repository
    59          baseurl=https://yum.dockerproject.org/repo/main/centos/7
    60          enabled=1
    61          gpgcheck=1
    62          gpgkey=https://yum.dockerproject.org/gpg
    63          EOF
    64  
    65  4. Install the Docker package.
    66  
    67          $ sudo yum install docker-engine
    68  
    69  5. Start the Docker daemon.
    70  
    71          $ sudo service docker start
    72  
    73  6. Verify `docker` is installed correctly by running a test image in a container.
    74  
    75          $ sudo docker run hello-world
    76          Unable to find image 'hello-world:latest' locally
    77      		latest: Pulling from hello-world
    78      		a8219747be10: Pull complete
    79      		91c95931e552: Already exists
    80      		hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
    81      		Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd1.7.1cf5daeb82aab55838d
    82      		Status: Downloaded newer image for hello-world:latest
    83      		Hello from Docker.
    84      		This message shows that your installation appears to be working correctly.
    85  
    86      		To generate this message, Docker took the following steps:
    87      		 1. The Docker client contacted the Docker daemon.
    88      		 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    89      				(Assuming it was not already locally available.)
    90      		 3. The Docker daemon created a new container from that image which runs the
    91      				executable that produces the output you are currently reading.
    92      		 4. The Docker daemon streamed that output to the Docker client, which sent it
    93      				to your terminal.
    94  
    95      		To try something more ambitious, you can run an Ubuntu container with:
    96      		 $ docker run -it ubuntu bash
    97  
    98      		For more examples and ideas, visit:
    99      		 http://docs.docker.com/userguide/
   100  
   101  ### Install with the script
   102  
   103  
   104  1. Log into your machine as a user with `sudo` or `root` privileges.
   105  
   106  2. Make sure your existing yum packages are up-to-date.
   107  
   108  		$ sudo yum update
   109  
   110  3. Run the Docker installation script.
   111  
   112  		$ curl -sSL https://get.docker.com/ | sh
   113  
   114  	This script adds the `docker.repo` repository and installs Docker.
   115  
   116  4. Start the Docker daemon.
   117  
   118  		$ sudo service docker start
   119  
   120  5. Verify `docker` is installed correctly by running a test image in a container.
   121  
   122  		$ sudo docker run hello-world
   123  
   124  
   125  ## Create a docker group		
   126  
   127  The `docker` daemon binds to a Unix socket instead of a TCP port. By default
   128  that Unix socket is owned by the user `root` and other users can access it with
   129  `sudo`. For this reason, `docker` daemon always runs as the `root` user.
   130  
   131  To avoid having to use `sudo` when you use the `docker` command, create a Unix
   132  group called `docker` and add users to it. When the `docker` daemon starts, it
   133  makes the ownership of the Unix socket read/writable by the `docker` group.
   134  
   135  >**Warning**: The `docker` group is equivalent to the `root` user; For details
   136  >on how this impacts security in your system, see [*Docker Daemon Attack
   137  >Surface*](../articles/security.md#docker-daemon-attack-surface) for details.
   138  
   139  To create the `docker` group and add your user:
   140  
   141  1. Log into Centos as a user with `sudo` privileges.
   142  
   143  2. Create the `docker` group and add your user.
   144  
   145      `sudo usermod -aG docker your_username`
   146  
   147  3. Log out and log back in.
   148  
   149      This ensures your user is running with the correct permissions.
   150  
   151  4. Verify your work by running `docker` without `sudo`.
   152  
   153  		$ docker run hello-world
   154  
   155  ## Start the docker daemon at boot
   156  
   157  To ensure Docker starts when you boot your system, do the following:
   158  
   159        $ sudo chkconfig docker on
   160  
   161  If you need to add an HTTP Proxy, set a different directory or partition for the
   162  Docker runtime files, or make other customizations, read our Systemd article to
   163  learn how to [customize your Systemd Docker daemon options](../articles/systemd.md).
   164  
   165  
   166  ## Uninstall
   167  
   168  You can uninstall the Docker software with `yum`.  
   169  
   170  1. List the package you have installed.
   171  
   172  		$ yum list installed | grep docker
   173  		yum list installed | grep docker
   174  		docker-engine.x86_64   1.7.1-1.el7 @/docker-engine-1.7.1-1.el7.x86_64.rpm
   175  
   176  2. Remove the package.
   177  
   178  		$ sudo yum -y remove docker-engine.x86_64
   179  
   180  	This command does not remove images, containers, volumes, or user-created
   181  	configuration files on your host.
   182  
   183  3. To delete all images, containers, and volumes, run the following command:
   184  
   185  		$ rm -rf /var/lib/docker
   186  
   187  4. Locate and delete any user-created configuration files.