seshukm | ec1cf23 | 2018-08-22 15:49:51 +0800 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 2 | .. http://creativecommons.org/licenses/by/4.0 |
| 3 | .. Copyright 2018 Huawei Technologies Co., Ltd. |
| 4 | |
| 5 | Install Docker |
| 6 | =============== |
| 7 | |
| 8 | Make sure curl is installed on the Ubuntu VM: |
| 9 | |
| 10 | .. code-block:: bash |
| 11 | |
| 12 | sudo apt update |
| 13 | sudo apt install curl |
| 14 | |
| 15 | If you are behind a corporate firewall (replace "proxyhost:port" with your actual proxy information) |
| 16 | https_proxy="https://*proxyhost:port*" curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add - |
| 17 | |
| 18 | Otherwise: |
| 19 | curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add - |
| 20 | Expected Response: |
| 21 | OK |
| 22 | Add the docker package repository: |
| 23 | sudo apt-add-repository "deb https://apt.dockerproject.org/repo ubuntu-xenial main" |
| 24 | |
| 25 | Install packages: |
| 26 | |
| 27 | .. code-block:: bash |
| 28 | |
| 29 | sudo apt update |
| 30 | sudo apt-cache policy docker-engine |
| 31 | sudo apt install docker-engine |
| 32 | sudo apt install docker-compose |
| 33 | |
| 34 | If you are behind a corporate firewall, you will need to configure proxy settings for docker so that images may be obtained from internet repositories. In the commands shown here, replace *"proxyhost:port"*, *"yourdomain1.com"*, and *"yourdomain2.com"* with appropriate values. |
| 35 | |
| 36 | Make the docker configuration directory: |
| 37 | |
| 38 | .. code-block:: bash |
| 39 | |
| 40 | sudo mkdir -p /etc/systemd/system/docker.service.d |
| 41 | |
| 42 | Edit (create) this file: |
| 43 | |
| 44 | .. code-block:: bash |
| 45 | |
| 46 | sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf |
| 47 | |
| 48 | Add these lines: |
| 49 | |
| 50 | [Service] |
| 51 | |
| 52 | Environment="HTTP_PROXY=https://*proxyhost:port*" |
| 53 | |
| 54 | Environment="HTTPS_PROXY=https://*proxyhost:port*" |
| 55 | |
| 56 | Environment="NO_PROXY=localhost,127.0.0.1,.yourdomain1.com,.yourdomain2.com" |
| 57 | |
| 58 | Restart docker: |
| 59 | |
| 60 | .. code-block:: bash |
| 61 | |
| 62 | sudo systemctl daemon-reload |
| 63 | sudo systemctl restart docker |
| 64 | |
| 65 | Add yourself to the docker user group (replace "userid" with your user ID): |
| 66 | |
| 67 | .. code-block:: bash |
| 68 | |
| 69 | sudo usermod -a -G docker *userid* |
| 70 | |
| 71 | Log out and log back in so that the user group change will takeeffect. |
| 72 | |
| 73 | Verify that you can connect to docker as yourself (i.e. not as root): |
| 74 | |
| 75 | .. code-block:: bash |
| 76 | |
| 77 | docker ps |
| 78 | |
| 79 | Verify that you can download and run the hello-world container |
| 80 | |
| 81 | .. code-block:: bash |
| 82 | |
| 83 | docker run hello-world |
| 84 | |
| 85 | .. image:: images/Docker_install_1.png |