github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/docs/installation/linux/centos.md (about)

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