美文网首页
linux无外网情况下docker环境搭建和导入导出镜像

linux无外网情况下docker环境搭建和导入导出镜像

作者: 青果山圣斗士 | 来源:发表于2021-05-12 18:13 被阅读0次

    针对无网络情况下的docker环境搭建

    下载文件
    https://download.docker.com/linux/static/stable/

    解压

    tar xzvf docker-19.03.5.tgz 
    

    拷贝

    sudo cp docker/* /usr/bin/
    

    配置service文件

    vi /usr/lib/systemd/system/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
    ExecStart=/usr/bin/dockerd
    ExecReload=/bin/kill -s HUP $MAINPID
    LimitNOFILE=infinity
    LimitNPROC=infinity
    TimeoutStartSec=0
    Delegate=yes
    KillMode=process
    Restart=on-failure
    StartLimitBurst=3
    StartLimitInterval=60s
     
    [Install]
    WantedBy=multi-user.target
    

    启动dockerd服务进程

    systemctl daemon-reload
    systemctl start docker.service
    

    至此docker部署完成

    从外部导出想用的image文件

    docker images
    
    REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
    docker.io/memcached                             latest              9f547b64a127        3 months ago        82.4 MB
    docker.io/openzipkin/zipkin                     latest              9b4acc3eb019        4 months ago        150 MB
    docker.io/mysql                                 5.7                 f07dfa83b528        4 months ago        448 MB
    docker.io/mysql                                 latest              a347a5928046        4 months ago        545 MB
    docker.io/redis                                 latest              ef47f3b6dc11        5 months ago        104 MB
    docker.io/mongo                                 4.4.1               ba0c2ff8d362        7 months ago        492 MB
    docker.io/mongo                                 latest              ba0c2ff8d362        7 months ago        492 MB
    docker.io/openzipkin/zipkin                     2.21                1850194f377c        8 months ago        160 MB
    docker.io/mongo                                 4.2.2               a0e2e64ac939        17 months ago       364 MB
    docker.elastic.co/elasticsearch/elasticsearch   7.5.0               911f580307ae        17 months ago       766 MB
    docker.io/hello-world                           latest              fce289e99eb9        2 years ago         1.84 kB
    

    导出 docker save [IMAGE ID] > file.tar

    docker save ba0c2ff8d362 > mongo.tar
    

    将文件拷贝到目标机器

    导入 docker load < file.tar

    docker load < mongo.tar
    
    docker load < mongo.tar 
    805802706667: Loading layer [==================================================>]  65.61MB/65.61MB
    3fd9df553184: Loading layer [==================================================>]  15.87kB/15.87kB
    7a694df0ad6c: Loading layer [==================================================>]  3.072kB/3.072kB
    a021cd73dfaf: Loading layer [==================================================>]  402.9kB/402.9kB
    12edaa53e545: Loading layer [==================================================>]  7.811MB/7.811MB
    702d400a4563: Loading layer [==================================================>]  13.76MB/13.76MB
    cfc0697113b6: Loading layer [==================================================>]  1.536kB/1.536kB
    43186b284569: Loading layer [==================================================>]   5.12kB/5.12kB
    d42ff58d525e: Loading layer [==================================================>]  3.584kB/3.584kB
    eefef2db9280: Loading layer [==================================================>]  408.9MB/408.9MB
    6fe14568cbd3: Loading layer [==================================================>]   2.56kB/2.56kB
    690c3d4de4fc: Loading layer [==================================================>]  14.34kB/14.34kB
    Loaded image ID: sha256:ba0c2ff8d3620c0910832424efef02787214013b1c5b1d9dc9d87d638e2ceb71
    

    导入镜像没有tag,需要自己指定

    docker images
    
    docker images
    REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
    <none>       <none>    ba0c2ff8d362   7 months ago   492MB
    

    docker tag [IMAGE ID] tag:version

    docker tag ba0c2ff8d362 mongo
    

    启动

    docker run -itd --restart=always --name mongo1 -p 27001:27017 -v /data/mongodb_data:/data/db mongo:latest --replSet test
    

    相关文章

      网友评论

          本文标题:linux无外网情况下docker环境搭建和导入导出镜像

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