本文共 3144 字,大约阅读时间需要 10 分钟。
Docker currently only runs on 64-bits platforms and requires that the kernal version be no less than 3.10.
in this tutorial , i use ubuntu 16.04 and the kernal version is 4.13.0-43-generic you can use this command to find your linux-version and linux-kernal version.uname -a cat /proc/version
At the first , you need to update your existing list of packages:
sudo apt update
Second, you need to install a few prerequisite packages which let apt use packages over HTTPS
sudo apt install apt-transport-https ca-certificates curl software-properties-common
add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
update the package database with the Docker packages from the newly added repo:
sudo apt-get update
After you can install Docker
sudo apt-get install docker-ce
if you have error on apt-get like this :
you can use this command to find the process using apt , and kill it !ps aux | grep aptafter that , how can you check that docker is installed ?you can use this command to chek
sudo service docker start docker version
Than,test that your installation works by running the simple Docker image, hello-world:
root@ubuntu:~# docker run hello-worldHello from Docker!This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID: https://hub.docker.com/For more examples and ideas, visit: https://docs.docker.com/get-started/
List the hello-world container (spawned by the image) which exits after displaying its message. If it were still running, you would not need the --all option:
root@ubuntu:~# docker container ls --allCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES46ea9cb299d4 hello-world "/hello" 2 minutes ago Exited (0) 2 minutes ago objective_mestorf1d9c5cbbed49 hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago goofy_diffiefef4ade3de12 hello-world "/hello" 22 minutes ago Exited (0) 22 minutes ago pensive_brown6d77512305e5 hello-world "/hello" 22 minutes ago Exited (0) 22 minutes ago vigorous_heyrovsky
Reference:
转载于:https://blog.51cto.com/12098022/2294095