linux下安装与运行docker

Posted Jello

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux下安装与运行docker相关的知识,希望对你有一定的参考价值。

写者环境:

1.lsb_release -a

[email protected]:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

2.更新apt和安装gpg秘钥

2.1 sudo apt-get update

2.2 sudo apt-get install apt-transport-https ca-certificates

2.3 sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

3.编辑源文件

sudo vi /etc/apt/source.list.d/docker.list (此文件不存在就直接创建即可)

将文件中的所有内容都删掉,然后写入内容入下:

deb https://apt.dockerproject.org/repo ubuntu-xenial main

4.更新apt包索引

sudo apt-get update

5.安装docker

sudo apt-get install docker-engine

6.启动docker

sudo service docker start

7.验证docker是否正在运行

sudo docker run hello-world

写者运行结果如下:

[email protected]:~$ sudo docker run hello-world
Unable to find image ‘hello-world:latest‘ locally
latest: Pulling from library/hello-world
b04784fba78d: Pull complete
Digest: sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
Status: Downloaded newer image for hello-world:latest

Hello 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.
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 bash

Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

8.将当前用户加入到docker组

sudo usermod -a -G docker hello

9.重启docker

sudo service docker restart

 





















以上是关于linux下安装与运行docker的主要内容,如果未能解决你的问题,请参考以下文章

Linux(CentOS7)下Docker的安装与卸载

linux(centos7.4)下安装docker

Linux下Docker安装

linux 下安装docker

linux centos下安装docker

Docker在Linux下安装与配置Docker环境