zoukankan      html  css  js  c++  java
  • 【Docker】在Linux系统中安装Docker虚拟机、启动停止重启查看Docker命令

    安装Docker

    Docker虚拟机架构

    Docker创建的所有虚拟实例共用同一个Linux内核,对硬件占用较少,属于轻量级虚拟机

    在这里插入图片描述

    Docker的版本定义

    Docker Engine

    • 社区版 ( CE, Community Edition )
    • 企业版 ( EE, Enterprise Edition )

    社区版提供了Docker中的容器管理等基础功能,企业版增加了容器管理、镜像管理、插件、安全等服务与功能,还有就是一个免费一个收费。

    Docker的环境依赖

    Docker依赖Linux内核中的相关支持,kernel 核心。

    建议将系统升级到能支持 Docker 的系统版本。
    在这里插入图片描述

    我使用的是Linux CentOS 7

    在Linux系统中安装Docker虚拟机

    https://docs.docker.com/engine/install/centos/

    CentOS

    先更新yum软件管理,然后再安装Docker

    yum -y update
    yum install -y docker
    
    

    -y代表选择程序安装中的yes选项

    我的执行

    [root@liuawen ~]# yum -y update
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    No packages marked for update
    [root@liuawen ~]# yum install -y docker
    ...
    

    出现问题

    Error: docker-ce-cli conflicts with 2:docker-1.13.1-109.gitcccb291.el7.centos.x86_64
    Error: docker-ce conflicts with 2:docker-1.13.1-109.gitcccb291.el7.centos.x86_64
     You could try using --skip-broken to work around the problem
     You could try running: rpm -Va --nofiles --nodigest
    [root@liuawen ~]# 
    

    我之前安装过docker了,那就卸载掉重新安装下。

    yum list installed | grep docker

    yum -y remove xxx

    [root@liuawen ~]# yum list installed | grep docker
    containerd.io.x86_64            1.2.13-3.1.el7                 @docker-ce-stable
    docker-ce.x86_64                3:19.03.8-3.el7                @docker-ce-stable
    docker-ce-cli.x86_64            1:19.03.8-3.el7                @docker-ce-stable
    [root@liuawen ~]#  yum -y remove containerd.io.x86_64 docker-ce.x86_64   docker-ce-cli.x86_64 
    Loaded plugins: fastestmirror
    Resolving Dependencies
    ...
    
    

    再安装yum install -y docker

    在这里插入图片描述

    安装好了

    启动docker:systemctl start docker

    停止docker:systemctl stop docker

    重启docker:systemctl restart docker

    查看docker状态:systemctl status docker

    开机启动:systemctl enable docker

    [root@liuawen local]# systemctl start docker
    [root@liuawen local]# ps -ef | grep "docker"
    root     25171     1  0 11:14 ?        00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
    root     25177 25171  0 11:14 ?        00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
    root     25887 21199  0 11:24 pts/2    00:00:00 grep --color=auto docker
    [root@liuawen local]# systemctl stop docker
    [root@liuawen local]# ps -ef | grep "docker"
    root     25910 21199  0 11:24 pts/2    00:00:00 grep --color=auto docker
    [root@liuawen local]# systemctl restart docker
    [root@liuawen local]# ps -ef | grep "docker"
    root     25960     1  2 11:24 ?        00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
    root     25966 25960  0 11:24 ?        00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
    root     26063 21199  0 11:25 pts/2    00:00:00 grep --color=auto docker
    [root@liuawen local]# 
    

    https://docs.docker.com/engine/install/ubuntu/
    Ubuntu

    $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
    $
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    $ sudo apt-get update
    $ sudo apt-get install docker-ce
    $
    $ sudo systemctl enable docker
    $ sudo systemctl start docker
    

    管理Docker虚拟机

    启动Docker服务

    systemctl start docker
    

    实现 Docker 服务开机自启动

    systemctl enable docker
    
    [root@liuawen ~]# systemctl start docker
    [root@liuawen ~]# systemctl enable docker
    [root@liuawen ~]# 
    
    

    停止docker:systemctl stop docker

    重启docker:systemctl restart docker

    查看docker状态:systemctl status docker

    docker version

    查看Docker版本

    [root@liuawen ~]# docker version
    Client:
     Version:         1.13.1
     API version:     1.26
     Package version: docker-1.13.1-109.gitcccb291.el7.centos.x86_64
     Go version:      go1.10.3
     Git commit:      cccb291/1.13.1
     Built:           Tue Mar  3 17:21:24 2020
     OS/Arch:         linux/amd64
    
    Server:
     Version:         1.13.1
     API version:     1.26 (minimum version 1.12)
     Package version: docker-1.13.1-109.gitcccb291.el7.centos.x86_64
     Go version:      go1.10.3
     Git commit:      cccb291/1.13.1
     Built:           Tue Mar  3 17:21:24 2020
     OS/Arch:         linux/amd64
     Experimental:    false
    [root@liuawen ~]# 
    
    

    Docker C/S 客户端服务端相关的版本信息

    docker info

    更多的Docker相关信息

    [root@liuawen ~]# docker info
    Containers: 0
     Running: 0
     Paused: 0
     Stopped: 0
    Images: 0
    Server Version: 1.13.1
    Storage Driver: overlay2
     Backing Filesystem: extfs
     Supports d_type: true
     Native Overlay Diff: true
    Logging Driver: journald
    Cgroup Driver: systemd
    Plugins: 
     Volume: local
     Network: bridge host macvlan null overlay
    Swarm: inactive
    Runtimes: docker-runc runc
    Default Runtime: docker-runc
    Init Binary: /usr/libexec/docker/docker-init-current
    containerd version:  (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
    runc version: 66aedde759f33c190954815fb765eedc1d782dd9 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
    init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
    Security Options:
     seccomp
      WARNING: You're not using the default seccomp profile
      Profile: /etc/docker/seccomp.json
    Kernel Version: 3.10.0-1062.12.1.el7.x86_64
    Operating System: CentOS Linux 7 (Core)
    OSType: linux
    Architecture: x86_64
    Number of Docker Hooks: 3
    CPUs: 2
    Total Memory: 3.7 GiB
    Name: liuawen
    ID: EIFQ:YIQM:CYL2:LDKU:AOII:WBJB:UXTN:WBXV:3PZO:JH4D:E7UG:RA3A
    Docker Root Dir: /var/lib/docker
    Debug Mode (client): false
    Debug Mode (server): false
    Registry: https://index.docker.io/v1/
    Experimental: false
    Insecure Registries:
     127.0.0.0/8
    Live Restore Enabled: false
    Registries: docker.io (secure)
    [root@liuawen ~]# 
    

    参考资料

    简单记录
    1、https://docs.docker.com/engine/
    2、https://docs.docker.com/engine/install/centos/
    3、开发者必备的 Docker 实践指南 掘金小册
    4、Docker环境下的前后端分离项目部署与运维

  • 相关阅读:
    shift and/or 算法
    FFT求解字符串匹配
    hdu 6981/ 2021“MINIEYE杯”中国大学生算法设计超级联赛(3)1009 Rise in Price(剪枝,dp合并)
    Rancher监控指标一文干到底(workload metrics)
    RocketMQ详解(二)启动运行原理
    新人如何快速剖析源码
    RocketMQ详解(三)核心设计原理(待完善)
    windows powershell下载文件的4种方式
    windows 调用bat脚本时pause处理
    python3 中的b''解析
  • 原文地址:https://www.cnblogs.com/liuawen/p/12854028.html
Copyright © 2011-2022 走看看