github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/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 These instructions install Docker using release packages and installation 20 mechanisms managed by Docker, to be sure that you get the latest version 21 of Docker. If you wish to install using CentOS-managed packages, consult 22 your CentOS release documentation. 23 24 ## Prerequisites 25 26 Docker requires a 64-bit OS and version 3.10 or higher of the Linux kernel. 27 28 To check your current kernel version, open a terminal and use `uname -r` to 29 display your kernel version: 30 31 ```bash 32 $ uname -r 33 3.10.0-229.el7.x86_64 34 ``` 35 36 Finally, it is recommended that you fully update your system. Keep in mind 37 that your system should be fully patched to fix any potential kernel bugs. 38 Any reported kernel bugs may have already been fixed on the latest kernel 39 packages. 40 41 ## Install Docker Engine 42 43 There are two ways to install Docker Engine. You can [install using the `yum` 44 package manager](#install-with-yum). Or you can use `curl` with the [`get.docker.com` 45 site](#install-with-the-script). This second method runs an installation script 46 which also installs via the `yum` package manager. 47 48 ### Install with yum 49 50 1. Log into your machine as a user with `sudo` or `root` privileges. 51 52 2. Make sure your existing packages are up-to-date. 53 54 ```bash 55 $ sudo yum update 56 ``` 57 58 3. Add the `yum` repo. 59 60 ```bash 61 $ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF' 62 [dockerrepo] 63 name=Docker Repository 64 baseurl=https://yum.dockerproject.org/repo/main/centos/7/ 65 enabled=1 66 gpgcheck=1 67 gpgkey=https://yum.dockerproject.org/gpg 68 EOF 69 ``` 70 71 4. Install the Docker package. 72 73 ```bash 74 $ sudo yum install docker-engine 75 ``` 76 77 5. Enable the service. 78 79 ```bash 80 $ sudo systemctl enable docker.service 81 ``` 82 83 6. Start the Docker daemon. 84 85 ```bash 86 $ sudo systemctl start docker 87 ``` 88 89 7. Verify `docker` is installed correctly by running a test image in a container. 90 91 $ sudo docker run --rm hello-world 92 93 Unable to find image 'hello-world:latest' locally 94 latest: Pulling from library/hello-world 95 c04b14da8d14: Pull complete 96 Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9 97 Status: Downloaded newer image for hello-world:latest 98 99 Hello from Docker! 100 This message shows that your installation appears to be working correctly. 101 102 To generate this message, Docker took the following steps: 103 1. The Docker client contacted the Docker daemon. 104 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 105 3. The Docker daemon created a new container from that image which runs the 106 executable that produces the output you are currently reading. 107 4. The Docker daemon streamed that output to the Docker client, which sent it 108 to your terminal. 109 110 To try something more ambitious, you can run an Ubuntu container with: 111 $ docker run -it ubuntu bash 112 113 Share images, automate workflows, and more with a free Docker Hub account: 114 https://hub.docker.com 115 116 For more examples and ideas, visit: 117 https://docs.docker.com/engine/userguide/ 118 119 If you need to add an HTTP Proxy, set a different directory or partition for the 120 Docker runtime files, or make other customizations, read our Systemd article to 121 learn how to [customize your Systemd Docker daemon options](../../admin/systemd.md). 122 123 ### Install with the script 124 125 1. Log into your machine as a user with `sudo` or `root` privileges. 126 127 2. Make sure your existing packages are up-to-date. 128 129 ```bash 130 $ sudo yum update 131 ``` 132 133 3. Run the Docker installation script. 134 135 ```bash 136 $ curl -fsSL https://get.docker.com/ | sh 137 ``` 138 139 This script adds the `docker.repo` repository and installs Docker. 140 141 4. Enable the service. 142 143 ```bash 144 $ sudo systemctl enable docker.service 145 ``` 146 147 5. Start the Docker daemon. 148 149 ```bash 150 $ sudo systemctl start docker 151 ``` 152 153 6. Verify `docker` is installed correctly by running a test image in a container. 154 155 ```bash 156 $ sudo docker run hello-world 157 ``` 158 159 If you need to add an HTTP Proxy, set a different directory or partition for the 160 Docker runtime files, or make other customizations, read our Systemd article to 161 learn how to [customize your Systemd Docker daemon options](../../admin/systemd.md). 162 163 ## Create a docker group 164 165 The `docker` daemon binds to a Unix socket instead of a TCP port. By default 166 that Unix socket is owned by the user `root` and other users can access it with 167 `sudo`. For this reason, `docker` daemon always runs as the `root` user. 168 169 To avoid having to use `sudo` when you use the `docker` command, create a Unix 170 group called `docker` and add users to it. When the `docker` daemon starts, it 171 makes the ownership of the Unix socket read/writable by the `docker` group. 172 173 >**Warning**: The `docker` group is equivalent to the `root` user; For details 174 >on how this impacts security in your system, see [*Docker Daemon Attack 175 >Surface*](../../security/security.md#docker-daemon-attack-surface) for details. 176 177 To create the `docker` group and add your user: 178 179 1. Log into your machine as a user with `sudo` or `root` privileges. 180 181 2. Create the `docker` group. 182 183 ```bash 184 $ sudo groupadd docker 185 ``` 186 187 3. Add your user to `docker` group. 188 189 ```bash 190 $ sudo usermod -aG docker your_username` 191 ``` 192 193 4. Log out and log back in. 194 195 This ensures your user is running with the correct permissions. 196 197 5. Verify that your user is in the docker group by running `docker` without `sudo`. 198 199 ```bash 200 $ docker run hello-world 201 ``` 202 203 ## Start the docker daemon at boot 204 205 Configure the Docker daemon to start automatically when the host starts: 206 207 ```bash 208 $ sudo systemctl enable docker 209 ``` 210 211 ## Uninstall 212 213 You can uninstall the Docker software with `yum`. 214 215 1. List the installed Docker packages. 216 217 ```bash 218 $ yum list installed | grep docker 219 220 docker-engine.x86_64 1.7.1-0.1.el7@/docker-engine-1.7.1-0.1.el7.x86_64 221 ``` 222 223 2. Remove the package. 224 225 ```bash 226 $ sudo yum -y remove docker-engine.x86_64 227 ``` 228 229 This command does not remove images, containers, volumes, or user-created 230 configuration files on your host. 231 232 3. To delete all images, containers, and volumes, run the following command: 233 234 ```bash 235 $ rm -rf /var/lib/docker 236 ``` 237 238 4. Locate and delete any user-created configuration files.