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