Ubuntu16.04 install docker

1. Install dependencies

sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common

 2. Add Docker official GPG key

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

After success, the terminal displays OK, as shown in the figure:


 3. Add the docker library to the current apt library

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

 4. Update the apt package

sudo apt-get update

 5. List docker available versions

apt-cache madison docker-ce

The second column is the version number


6. Select the appropriate version

As shown in the last line of the figure above, if you select version 17.12.0, execute:

sudo apt-get install -y docker-ce=17.12.0~ce-0~ubuntu

The download may fail due to network reasons. You can copy the download link to open the download in the browser or use a downloader such as Thunder, as shown in the figure.

It can be seen that the network link has timed out (Operation timed out), but you can see that the download link is: https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_17.12.0~ce -0~ubuntu_amd64.deb , then copy the link to the browser to download. (The blogger downloaded it in this way, and the above picture is also a screenshot of my actual operation)

After downloading the .deb file ( if the installation is successful via apt-get, skip this step ), execute:

sudo dpkg -i docker-ce_17.12.0_ce-0_ubuntu_amd64.deb 

 7. Verify that docker is started

implement:

systemctl status docker

If the above picture is displayed, it means it is enabled, otherwise, execute the following command to start the docker service:

sudo systemctl start docker

8. Use docker without sudo

Add the password-free user to the docker user group and execute the following command:

sudo gpasswd -a $USER docker (Note: $USER can be replaced with a password-free username)
newgrp docker

 9.hello-world

implement:

docker run hello-world

The above picture shows that the installation is successful.  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324783162&siteId=291194637