美文网首页
2018-08-27 第一、二章 搭建容器

2018-08-27 第一、二章 搭建容器

作者: 鸭鸭学语言 | 来源:发表于2018-08-28 05:24 被阅读0次

    传统的OS

    1. install centos mini

    2. virtualbox 虚机网桥配置:

    修改网卡类型为网桥

    vi /etc/sysconfig/network-script/ifcfg-enp0s3   add lines below:

    HWADDR=08:00:27:2E:8B:3C

    BOOTPROTO=static

    IPADDR=192.168.0.9

    NETMASK=255.255.255.0

    GATEWAY=192.168.0.1

    DNS1=8.8.8.8

    DNS2=4.4.4.4

    3. 更改主机名:

    hostnamectl set-hostname k8s-centos-mini

    4. install docker:

    # yum update

    # yum install docker

    # systemctl enable docker.service

    # systemctl start docker.service

    5. 查看docker软件包的构成

    # rpm -ql docker | more

    /etc/docker

    /etc/docker/certs.d

    /etc/docker/certs.d/redhat.com

    /etc/docker/certs.d/redhat.com/redhat-ca.crt

    /etc/docker/certs.d/redhat.io

    /etc/docker/certs.d/redhat.io/redhat-ca.crt

    /etc/docker/certs.d/registry.access.redhat.com

    /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt

    //...... Above, 使centos、redhat能使用REdhat自己的registry,而不仅是Docker Hub Registry(https://registry.hub.docker.com / account:josiejiao)

    //        PS:对RHEL,docker软件包还安装了/usr/share/rhel/secrets 目录,它们是关于订阅管理文件,将被复制到容器中,所以容器无需消耗额外的订阅

    /etc/sysconfig/docker-network    --> 用于收集传给docker服务的网络选项

    /etc/sysconfig/docker-storage    --> 用来改变Docker服务的存储数据的方式的output设置, 默认DOCKER_STORAGE_OPTIONS="--storage-driver overlay2 "

    /etc/sysconfig/docker-storage-setup  --> --> 用来改变Docker服务的存储数据的方式的input设置,  默认STORAGE_DRIVER=overlay2

    // Docker的存储后端可以定义多种:devicemapper, overlay, and overlay2

    6. Docker command

      attach      Attach to a running container

      build      Build an image from a Dockerfile

      commit      Create a new image from a container's changes

      cp          Copy files/folders between a container and the local filesystem

      create      Create a new container

      diff        Inspect changes on a container's filesystem

      events      Get real time events from the server

      exec        Run a command in a running container

      export      Export a container's filesystem as a tar archive

      history    Show the history of an image

      images      List images

      import      Import the contents from a tarball to create a filesystem image

      info        Display system-wide information

      inspect    Return low-level information on Docker objects

      kill        Kill one or more running containers

      load        Load an image from a tar archive or STDIN

      login      Log in to a Docker registry

      logout      Log out from a Docker registry

      logs        Fetch the logs of a container

      pause      Pause all processes within one or more containers

      port        List port mappings or a specific mapping for the container

      ps          List containers

      pull        Pull an image or a repository from a registry

      push        Push an image or a repository to a registry

      rename      Rename a container

      restart    Restart one or more containers

      rm          Remove one or more containers

      rmi        Remove one or more images

      run        Run a command in a new container

      save        Save one or more images to a tar archive (streamed to STDOUT by default)

      search      Search the Docker Hub for images

      start      Start one or more stopped containers

      stats      Display a live stream of container(s) resource usage statistics

      stop        Stop one or more running containers

      tag        Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

      top        Display the running processes of a container

      unpause    Unpause all processes within one or more containers

      update      Update configuration of one or more containers

      version    Show the Docker version information

      wait        Block until one or more containers stop, then print their exit codes

    ----------------------------------

    精简的专为运行容器的OS

    Atomic类  基于rpm的linux发型版构建器 

    www.projectatomic.io/docs/quickstart

    方案1. 云上部署 - qcow2格式的形式

    Fedora: https://alt.fedoraproject.org/cloud/, 有适用于opestack 的base cloud的qcow2

    Centos https://buildlogs.centos.org/centos/7/isos/x86_64/ , 有适用于云端的qcow2 CentOS-7-x86_64-AtomicHost-20141129_02.qcow2,通过cloud-init注入配置信息

    redhat: 适用于Red hat企业虚拟化平台的qcow2

    方案2. 通过宿主机的Vagrant(https://www.vagrantup.com),快速部署启动虚拟机 - Vagrant box镜像

    Fedora:https://alt.fedoraproject.org/cloud/, 有适合windows的virtual box版,和Fedora的KVM版

    Centos:  https://buildlogs.centos.org/centos/7/isos/x86_64/ 

    Redhat: 支持Hyper-V / Vmware的ova/vhd

    方案3. 传统ISO安装方式

    AtomicHost的维护

    实际上,atomic Host上 rpm和yum工具都不能用了

    替代 安装: 添加普通容器 实现安装应用, 添加特权容器 实现宿主机系统访问的工具安装

    替代 升级: # atomic host upgrade

    CoreOS类

    https://coreos.com/os/docs/latest/booting-with-iso.html

    方案1. live iso 安装

    fedora:  https://buildlogs.centos.org/centos/7/isos/x86_64/ 

    相关文章

      网友评论

          本文标题:2018-08-27 第一、二章 搭建容器

          本文链接:https://www.haomeiwen.com/subject/jlwxwftx.html