Sunday, June 19, 2022
HomeCyber Securityunable to organize context: path “…” not discovered | by Teri Radichel...

unable to organize context: path “…” not discovered | by Teri Radichel | Bugs That Chew | Jun, 2022


Packer can’t run docker command in a script

In case you are trying to run Docker in a Packer script you’ll have some points the place the Docker file path causes you grief.

Right here’s a pattern construction to reveal what I’m doing:

/residence/ec2-user/packer/run.sh
/residence/ec2-user/packer/templates/linux.json
/residence/ec2-user/packer/scripts/script1.sh
/residence/ec2-user/myapp/Dockerfile

After I name a script from throughout the linux.json file the script path ought to be relative to the run.sh file. So if I need to name script1.sh it might be:

scripts/script1.sh

Now I’m making an attempt to run a docker construct with a model of a path used to work:

docker construct -t 2sl/myapp /residence/ec2-user/myapp

However I’m getting this error with no matter path I attempt:

unable to organize context: path “/residence/ec2-user/myapp” not discovered

So the place am I when calling this script. Let’s see what else is within the present listing by calling this command from throughout the script that’s making an attempt to run the docker command.

ls

And I see this:

I’ve a few totally different instruments folder in my folder construction on the AMI the place I’m operating packer and that code ought to have been cloned into the AMI that’s at the moment executing instructions.

Let’s run one other ls to see what’s above this instruments listing.

ls ../

Aha. This instruments listing is within the residence listing, or ec2-user on the occasion making an attempt to execute this script.

Let’s see what’s within the instruments listing.

ls instruments

In my case, I see a folders for some repositories I clone all the way down to the AMI the place I retailer some instruments. That’s anticipated.

Drilling dow a bit additional I see that my recordsdata are lacking throughout the subdirectory.

What happed?

The docker command is on the lookout for recordsdata on the EC2 occasion that packer spins as much as construct the brand new picture.

The AMI I’m constructing is predicated on an AMI I constructed beforehand the place I copy recordsdata all the way down to the machine. So I went again to test that prior AMI model to see if it ran accurately and discover out why the recordsdata are lacking.

The AMI construct accomplished however there was an error I didn’t discover.

FIX: Make certain errors cease the construct so they don't seem to be missed.

The error is expounded to an IAM credentials subject and the recordsdata are failing to obtain from S3 in consequence. I feel this one could also be a bug.

____________________________________________

About this weblog:

Need to study extra about Cybersecurity and Cloud Safety? Take a look at: Cybersecurity for Executives within the Age of Cloud on Amazon

Want Cloud Safety Coaching? 2nd Sight Lab Cloud Safety Coaching

Is your cloud safe? Rent 2nd Sight Lab for a penetration check or safety evaluation.

Have a Cybersecurity or Cloud Safety Query? Ask Teri Radichel by scheduling a name with IANS Analysis.

Cybersecurity & Cloud Safety Assets by Teri Radichel: Cybersecurity and Cloud safety lessons, articles, white papers, shows, and podcasts

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments