admin 发表于 2018-2-15 22:12:36

ubuntu安装docker环境

安装docker
    各个操作系统的安装可以访问:
   https://docs.docker.com/engine/installation
docker分为开源的免费的CE版本和收费的EE版本:
以下实验环境,采用在ubuntu16.04操作系统上安装,使用docker版本为Docker CE版本:
          配置docker的apt源
            安装包:允许apt命令https访问docker源:
$sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common
   $sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
添加docker官方的GPG key
   
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

admin 发表于 2018-2-15 22:28:24

将docker的源添加到/etc/apt/sources.list
    sudo add-apt-repository"deb https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable"
安装docker
      更新源:
   sudo apt-get update
   安装docker-ce包
      apt-get install -y docker-ce

    安装更新了,安装失败:


   sudo grep device-mapper /proc/devices
252 device-mapper


如果没有出现就需要执行下面命令
    root@dockerserver:~# modprobe dm_mod
root@dockerserver:~# sudo grep device-mapper /proc/devices
252 device-mapper


安装docker这一步很关键,如果不是在天朝一个命令即可搞定:$ sudo apt-get install -y docker.io,但是我们最好使用国内的镜像源安装docker,不然那个安装速度真是比乌龟都慢。这里我们使用 DaoCloud 镜像站点(国内的一家公司),高速安装Docker,这里附上DaoCloud 官方安装文档:http://guide.daocloud.io/dcs/docker-9152677.html
$ curl -sSL https://get.daocloud.io/docker | sh 安装完docker以后,可以使用docker info命令来确认docker是否已经正常安装并运行。

admin 发表于 2018-2-15 23:52:53

docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 0
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version:(expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: N/A (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-21-generic
Operating System: Ubuntu 16.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.937 GiB
Name: dockerserver
ID: GIRM:EVPM:YTKL:DEVT:L2HM:ELGM:EYXU:3PDE:CHJB:D63L:KXWY:HSOD
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

admin 发表于 2018-2-15 23:53:38

使用sudo systemctl status docker命令可以查看docker运行状态
sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-02-15 23:51:11 CST; 2min 31s ago
   Docs: https://docs.docker.com
Main PID: 9615 (dockerd)
   CGroup: /system.slice/docker.service
         ├─9615 /usr/bin/dockerd -H fd://
         └─9620 containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/contai

Feb 15 23:51:11 dockerserver dockerd: time="2018-02-15T23:51:11.836995993+08:00" level=info msg="Loading containers: done."
Feb 15 23:51:11 dockerserver dockerd: time="2018-02-15T23:51:11.841195945+08:00" level=warning msg="Couldn't run auplink before unmount /var/lib/docker/tmp/docker-aufs-union3
Feb 15 23:51:11 dockerserver dockerd: time="2018-02-15T23:51:11.850940606+08:00" level=warning msg="failed to retrieve runc version: unknown output format: runc version spec:
Feb 15 23:51:11 dockerserver dockerd: time="2018-02-15T23:51:11.852341493+08:00" level=warning msg="failed to retrieve docker-init version: unknown output format: tini versio
Feb 15 23:51:11 dockerserver dockerd: time="2018-02-15T23:51:11.852810750+08:00" level=info msg="Daemon has completed initialization"
Feb 15 23:51:11 dockerserver dockerd: time="2018-02-15T23:51:11.853033183+08:00" level=info msg="Docker daemon" commit=092cba3 graphdriver=aufs version=1.13.1
Feb 15 23:51:11 dockerserver systemd: Started Docker Application Container Engine.
Feb 15 23:51:11 dockerserver dockerd: time="2018-02-15T23:51:11.867400168+08:00" level=info msg="API listen on /var/run/docker.sock"
Feb 15 23:52:41 dockerserver dockerd: time="2018-02-15T23:52:41.318996443+08:00" level=warning msg="failed to retrieve runc version: unknown output format: runc version spec:
Feb 15 23:52:41 dockerserver dockerd: time="2018-02-15T23:52:41.322871285+08:00" level=warning msg="failed to retrieve docker-init version: unknown output format: tini versio
lines 1-19/19 (END)
同样可以使用sudo systemctl stop/start/restart docker 来停止/启动/重启docker服务。

admin 发表于 2018-2-15 23:55:46

使用sudo systemctl stop/start/restart docker 来停止/启动/重启docker服务。

admin 发表于 2018-6-20 21:29:35

root@dockerserver:~# service docker status
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-06-20 21:23:55 CST; 6min ago
   Docs: https://docs.docker.com
Main PID: 12816 (dockerd)
   CGroup: /system.slice/docker.service
         ├─12816 /usr/bin/dockerd -H fd://
         └─12821 containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.so

Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.068545836+08:00" le
Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.180055748+08:00" le
Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.252103969+08:00" le
Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.257639954+08:00" le
Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.265876607+08:00" le
Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.267256613+08:00" le
Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.267785022+08:00" le
Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.268014925+08:00" le
Jun 20 21:23:55 dockerserver systemd: Started Docker Application Container Engine.
Jun 20 21:23:55 dockerserver dockerd: time="2018-06-20T21:23:55.284974707+08:00" le
lines 1-19/19 (END)
页: [1]
查看完整版本: ubuntu安装docker环境