• docker镜像的导入导出


    1、安装docker

    docker下载地址:https://download.docker.com/linux/static/stable/x86_64
    创建文件:vi docker.service

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target firewalld.service
    Wants=network-online.target
    [Service]
    Type=notify
    # the default is not to use systemd for cgroups because the delegate issues still
    # exists and systemd currently does not support the cgroup feature set required
    # for containers run by docker
    ExecStart=/usr/bin/dockerd
    ExecReload=/bin/kill -s HUP $MAINPID
    # Having non-zero Limit*s causes performance problems due to accounting overhead
    # in the kernel. We recommend using cgroups to do container-local accounting.
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    # Uncomment TasksMax if your systemd version supports it.
    # Only systemd 226 and above support this version.
    #TasksMax=infinity
    TimeoutStartSec=0
    # set delegate yes so that systemd does not reset the cgroups of docker containers
    Delegate=yes
    # kill only the docker process, not all processes in the cgroup
    KillMode=process
    # restart the docker process if it exits prematurely
    Restart=on-failure
    StartLimitBurst=3
    StartLimitInterval=60s
    [Install]
    WantedBy=multi-user.target
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31

    创建安装脚本:vi install.sh

    #!/bin/sh
    echo '解压tar包...'
    tar -xvf $1
    echo '将docker目录移到/usr/bin目录下...'
    cp docker/* /usr/bin/
    echo '将docker.service 移到/etc/systemd/system/ 目录...'
    cp docker.service /etc/systemd/system/
    echo '添加文件权限...'
    chmod +x /etc/systemd/system/docker.service
    echo '重新加载配置文件...'
    systemctl daemon-reload
    echo '启动docker...'
    systemctl start docker
    echo '设置开机自启...'
    systemctl enable docker.service
    echo 'docker安装成功...'
    docker –v
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    创建卸载脚本:vi uninstall.sh

    #!/bin/sh
    echo '删除docker.service...'
    rm -f /etc/systemd/system/docker.service
    echo '删除docker文件...'
    rm -rf /usr/bin/docker*
    echo '重新加载配置文件'
    systemctl daemon-reload
    echo '卸载成功...'
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    执行安装脚本:sh install.sh docker-17.03.0-ce.tgz

    启动docker:systemctl start docker
    重启docker:systemctl restart docker
    停止docker:systemctl stop docker
    启动容器:docker container start CONTAINER ID
    关闭容器:docker container stop CONTAINER ID
    重启容器:docker container restart CONTAINER ID
    删除容器:docker rm CONTAINER ID
    列出正在运行的容器:docker ps -a
    进入正在运行的容器:docker container exec -it 容器id /bin/bash
    传输文件命令:cp /opt/1.txt  CONTAINER ID:/home
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    配置国内源源:vi /etc/docker/daemon.json

    {
        "registry-mirrors": ["http://hub-mirror.c.163.com"]
    }
    
    • 1
    • 2
    • 3

    重启docker:systemctl restart docker

    2、导出镜像

    提交镜像:docker commit CONTAINER ID office
    导出镜像:docker save office> /opt/office.tar
    在这里插入图片描述

    3、导入镜像

    导入镜像:docker load < /opt/office.tar
    查看镜像:docker images
    删除镜像:docker rmi onlyoffice/documentserver(镜像名称)
    启动镜像:docker run -i -t -d -p 8099:80 IMAGE ID

  • 相关阅读:
    如何测试和调试Android应用程序
    展会预热 | 建模助手亮相住博会,亮点抢先看
    Java中的集合框架
    4.1 网络层提供的两种服务
    idea和maven常见问题
    机器学习随笔(1)——pandas.DataFrame和数据清洗
    Linux-vim使用
    java-net-php-python-ssm高校综合素质测评系统计算机毕业设计程序
    使用定时器获取转速信息(PWM频率)
    关于类和接口
  • 原文地址:https://blog.csdn.net/qq_37798548/article/details/126040129