码迷,mamicode.com
首页 > 其他好文 > 详细

Docker容器安装

时间:2018-11-14 18:54:34      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:ionic   top   bionic   ecc   nat   idg   core   安装和使用   option   

技术分享图片

Docker 安装和使用

1、在Ubuntu上安装docker,这里使用的版本是:Ubuntu18.04
安装apt-transport-https等软件包支持HTTPS协议源:

cobbler@cobbler-docker:~$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

添加源的gpg密钥:

cobbler@cobbler-docker:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK  

确认导入密钥:

cobbler@cobbler-docker:~$ sudo apt-key fingerprints 0EBFCD88
    pub   rsa4096 2017-02-22 [SCEA]
           9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
    sub   rsa4096 2017-02-22 [S]

获取当前操作系统的代号:
一般情况下,Ubuntu 16.04 LTS代号为xenial, Ubuntu 18.04 LTS代号为bionic

cobbler@cobbler-docker:~$ lsb_release -cs
    bionic

添加官方稳定版软件源:

        cobbler@cobbler-docker:~$ sudo add-apt-repository          "deb [arch=amd64] https://download.docker.com/linux/ubuntu          bionic          stable"

添加后需要更新apt软件包缓存:

cobbler@cobbler-docker:~$ sudo apt-get update

开始安装docker,安装成功之后、会自动启动docker服务

cobbler@cobbler-docker:~$ sudo apt-get install -y docker-ce

2、在centos安装docker、这里使用的版本为centos 7.5,需要提前配置好epel源、获取docker的repo文件和安装docker

[root@node7 ~]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/
[root@node7 ~]# yum -y install docker-ce

使用阿里云加速器、阿里云的镜像地址为 http://dev.aliyun.com 需要注册,使用自己的加速地址即可

[root@kvm-server ~]# mkdir -p /etc/docker
    [root@kvm-server docker]# vim daemon.json
    {
  "registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
    }

在启动之前需要改下docker的启动服务加一项iptables规则要不然启动之后forwar链上默认被改成DROP

[root@kvm-server docker]# vim /usr/lib/systemd/system/docker.service 
ExecStartPost=/usr/sbin/iptables -P FORWARD ACCEPT

重载文件、并启动docker服务

    [root@kvm-server docker]# systemctl daemon-reload
    [root@kvm-server docker]# systemctl restart docker

查看docker的信息

[root@node7 ~]#docker info 
Containers: 6
 Running: 6
 Paused: 0
 Stopped: 0
Images: 5
Server Version: 18.06.1-ce
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.779GiB
Name: node7.dklwj.com
ID: OST6:BVR7:UBAN:ACCI:YKPX:RLEM:DXKQ:QQPI:LYSY:PIVO:EUUA:4PQR
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Registry Mirrors:
 https://xxxxxxxxx.mirror.aliyuncs.com/
Live Restore Enabled: false

Docker容器安装

标签:ionic   top   bionic   ecc   nat   idg   core   安装和使用   option   

原文地址:http://blog.51cto.com/dklwj/2316745

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!