官术网_书友最值得收藏!

Installing on Linux

There are a lot of various Linux distributions out there and the installation process can be a little bit different for each Linux distribution. I'm going to install Docker on the latest, 16.04 Ubuntu desktop:

  1. First, we need to allow the apt package manager to use a repository over the HTTPS protocol. Execute from the shell:
$ sudo apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl software-properties-common
  1. The next thing we are going to do is add Docker's apt repository gpg key to our apt sources list:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
  1. A simple OK will be the response if succeeded. Use the following command to set up the stable repository:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  1. Next, we need to update the apt packages index:
$ sudo apt-get update  
  1. Now we need to make sure the apt installer will use the official Docker repository instead of the default Ubuntu repository (which may contain the older version of Docker):
$ apt-cache policy docker-ce  
  1. Use this command to install the latest version of Docker:
$ sudo apt-get install -y docker-ce
  1. The apt package manager will download a lot of packages; those will be the needed dependencies and the docker-engine itself:

  1. That's it, you should be all set. Let's verify if Docker works on our Linux box:
$sudo docker run milkyway/java-hello-world  
  1. As you can see, the Docker engine will pull the milkyway/java-hello-world image with all its layers from the Docker Hub and respond with a greeting:

But do we need to run Docker commands with sudo? The reason for that is the Docker daemon always runs as the root user, and since Docker version 0.5.2, the Docker daemon binds to a Unix socket instead of a TCP port. By default, that Unix socket is owned by the user root, and so, by default, you can access it with sudo. Let's fix it to be able to run the Docker command as a normal user:

  1. First, add the Docker group if it doesn't already exist:
$ sudo groupadd docker
  1. Then, add your own user to the Docker group. Change the username to match your preferred user:
$ sudo gpasswd -a jarek docker  
  1. Restart the Docker daemon:
$ sudo service docker restart  
  1. Now let's log out and log in again, and execute the docker run command one more time, without sudo this time. As you can see, you are now able to work with Docker as a normal, non-root user:
  1. That's it. Our Linux Docker installation is ready to play with. Let's do an installation on the Windows box now.
主站蜘蛛池模板: 凤城市| 卓尼县| 阜宁县| 武鸣县| 马公市| 舞钢市| 海林市| 闻喜县| 阳新县| 望城县| 大同县| 政和县| 裕民县| 清水河县| 蒙山县| 台北县| 宁国市| 那曲县| 基隆市| 新民市| 朝阳县| 东阿县| 建水县| 宜君县| 余庆县| 贞丰县| 林州市| 元氏县| 乃东县| 厦门市| 滕州市| 友谊县| 宁晋县| 凤冈县| 江都市| 疏勒县| 平乐县| 德钦县| 肇源县| 通城县| 葫芦岛市|