docker学习

<!doctype html>docker

 

一、docker安装

1、通过 uname -r 命令查看你当前的内核版本

 
 
 
xxxxxxxxxx
 
 
 
 
$ uname -r
 

2、使用 root 权限登录 Centos。确保 yum 包更新到最新。

 
 
 
xxxxxxxxxx
 
 
 
 
$ sudo yum update
 

3、卸载旧版本(如果安装过旧版本的话)

 
 
 
xxxxxxxxxx
 
 
 
 
$ sudo yum remove docker  docker-common docker-selinux docker-engine
 

4、安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

 
 
 
xxxxxxxxxx
 
 
 
 
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
 

5、设置yum源

 
 
 
xxxxxxxxxx
 
 
 
 
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
 

6、可以查看所有仓库中所有docker版本,并选择特定版本安装

 
 
 
xxxxxxxxxx
 
 
 
 
$ sudo yum list docker-ce --showduplicates | sort -r
 

7、安装docker

 
 
 
xxxxxxxxxx
 
 
 
 
$ sudo yum install docker-ce  #由于repo中默认只开启stable仓库,故这里安装的是最新稳定版17.12.0
$ sudo yum install <FQPN>  # 例如:sudo yum install docker-ce-17.12.0.ce
 

8、启动并加入开机启动

 
 
 
xxxxxxxxxx
 
 
 
 
$ sudo systemctl start docker
$ sudo systemctl enable docker
 

9、验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

 
 
 
xxxxxxxxxx
 
 
 
 
$ docker version
 

 

二、docker使用

1、Docker 命令概述

 
 
 
xxxxxxxxxx
 
 
 
 
镜像操作:
build     Build an image from a Dockerfile
    commit    Create a new image from a container's changes
    images    List images
    load      Load an image from a tar archive or STDIN
    pull      Pull an image or a repository from a registry
    push      Push an image or a repository to a registry
    rmi       Remove one or more images
    search    Search the Docker Hub for images
    tag       Tag an image into a repository
    save      Save one or more images to a tar archive (streamed to STDOUT by default)
    history   显示某镜像的历史
    inspect   获取镜像的详细信息
容器及其中应用的生命周期操作:
    create    Create a new container (创建一个容器)        
    kill      Kill one or more running containers
    inspect   Return low-level information on a container, image or task
    pause     Pause all processes within one or more containers
    ps        List containers
    rm        Remove one or more containers (删除一个或者多个容器)
    rename    Rename a container
    restart   Restart a container
    run       Run a command in a new container (创建并启动一个容器)
    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 (停止一个处于运行状态的容器)
    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
    wait      Block until a container stops, then print its exit code
    attach    Attach to a running container
    exec      Run a command in a running container
    port      List port mappings or a specific mapping for the container
    logs      获取容器的日志    
容器文件系统操作:
    cp        Copy files/folders between a container and the local filesystem
    diff      Inspect changes on a container's filesystem
    export    Export a container's filesystem as a tar archive
    import    Import the contents from a tarball to create a filesystem image
    Docker registry 操作:
    login     Log in to a Docker registry.
    logout    Log out from a Docker registry.
    Volume 操作
    volume    Manage Docker volumes
网络操作
network   Manage Docker networks
Swarm 相关操作
    swarm     Manage Docker Swarm
    service   Manage Docker services
    node      Manage Docker Swarm nodes       
系统操作:    
    version   Show the Docker version information
    events    Get real time events from the server  (持续返回docker 事件)
    info      Display system-wide information (显示Docker 主机系统范围内的信息)
 
posted @ 2019-08-16 17:17  忐忑忐忑  阅读(125)  评论(0编辑  收藏  举报