Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move Docker containers to AWS

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.

like image 641
Siva Sai Avatar asked Oct 26 '25 05:10

Siva Sai


1 Answers

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, ..)

like image 179
Jannik Weichert Avatar answered Oct 27 '25 21:10

Jannik Weichert