如何将Docker容器移至AWS [英] How to move Docker containers to AWS

查看:208
本文介绍了如何将Docker容器移至AWS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Docker容器从本地系统移动到AWs.我已经在本地系统中配置了docker.我需要将Docker容器从本地系统移至AWS EC2实例.

解决方案

在一次性场景中,您可以使用以下选项:

A:传输图像:

  1. 将图像保存在本地计算机上:

    docker save my_image > my_image.tar

  2. 将tar上传到您的远程服务器:

    scp my_image.tar user@aws-machine:.

  3. 在远程计算机上加载图像:

    ssh user@aws-machine

    docker load < my_image.tar

  4. 运行新容器

    docker run my_image

B:要转移容器,请执行以下操作:

  1. 将容器导出到本地计算机上:

    docker export my_container_id > my_container.tar

  2. 将tar上传到您的远程服务器:

    scp my_container.tar user@aws-machine:.

  3. 将tar作为映像加载到远程计算机上:

    ssh user@aws-machine

    cat my_container | docker import - my-container-exported:latest

  4. 运行新容器

    docker run my-container-exported:latest

要为以后的部署改进做准备(例如使用CD/CI),应考虑选项A.所有必需的执行数据都应在映像中,重要数据应存储在外部(卷装入,数据库等)./p>

How to move Docker container from.Local system to AWs.I have configured docker in my local system . I need to move docker container from my local system to aws EC2 instance.

解决方案

In a one time scenario you have these options:

A: To transfer your image:

  1. Save your image on your local machine:

    docker save my_image > my_image.tar

  2. Upload tar to your remote server:

    scp my_image.tar user@aws-machine:.

  3. Load image on your remote machine:

    ssh user@aws-machine

    docker load < my_image.tar

  4. Run a new container

    docker run my_image

B: To transfer your container:

  1. Export your container on your local machine:

    docker export my_container_id > my_container.tar

  2. Upload tar to your remote server:

    scp my_container.tar user@aws-machine:.

  3. Load tar as image on your remote machine:

    ssh user@aws-machine

    cat my_container | docker import - my-container-exported:latest

  4. Run a new container

    docker run my-container-exported:latest

To be prepared for later deployment improvements (like using CD/CI) you should consider option A. All necessary data for execution should be in the image and important data should be stored externally (volume mount, database, ..)

这篇关于如何将Docker容器移至AWS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆