Retrieve Docker-deployed files/source code on EC2

Pre-requisite:

6 STEPS to get your files back

  1. ssh into your EC2 instance
  • docker export dreamy_uranium > output.tar
  • For this command to work, you need to know exactly where your file is placed first.
  • Please also note the /local/path stated above is referring to the path on the EC2 instance (NOT the path to a location on your local computer).
  • realpath /home/ec2-user/output.tar
scp -i <private key> <user>@<host>:<server file path> <local path to download file>
  • Replace <private key> with e.g. mykey.pem
  • Replace <user>@<host> with e.g. ec2-user@ec2–52–201–115–3.ap-southeast-1.compute.amazonaws.com
  • Replace <server file path> with e.g. /home/ec2-user/output.tar
  • Replace <local path to download file> with e.g. /Users/Abc/Desktop *this is the path to a location on your local computer
Putting the example together:scp -i mykey.pem ec2-user@ec2–52–201–115–3.ap-southeast-1.compute.amazonaws.com:/home/ec2-user/output.tar /Users/Abc/Desktop
scp -r -i <private key> <user>@<host>:<server file path> <local path to download file>
  • This is mostly the same with 6.1, but with the newly added “-r” for downloading a directory. Refer to details in 6.1 for examples. With this, your source code should be directly downloaded.

Now your code is back. One less thing to worry about.

--

--

--

Nadie.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Using Sagemaker Processing Job to process parallelly

Flutter Scaffold Widget — Part 01: AppBar Explained

How To Make Dark Mode Work with All Apps on Android 10

How a software bug brought us into the history of the USSR

Manage Big Ball of Mud.

The Secrets to Avoiding Programmer Burnout as a New Developer

Day #8 with Cloud Workflows: calling an HTTP endpoint

How to use Async/Await in Unity

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
gw151226

gw151226

Nadie.

More from Medium

How to Run Docker Inside Docker?

Ski boot debugging

Setup an EC2 instance with ubuntu 20.04 server

Serialization Mechanism in Ansible