0

so I am trying to work out what the best way to call this function in my bash script so that is executed in the docker container.

#!/bin/bash

AWS_BUCKET="https://s3-bucket-location.com"
AWS_BUCKET_DEV_FILE="devfile.zip"
AWS_BUCKET_PIC_FILE="WORDPRESSpics.zip"

wordpress_production_S3_download () {
cd /tmp/
wget $AWS_BUCKET/$AWS_BUCKET_PIC_FILE
mv $AWS_BUCKET_PIC_FILE /var/www/html/wp-content/uploads/2017
cd /var/www/html/wp-content/uploads/2017
unzip $AWS_BUCKET_PIC_FILE
rm $AWS_BUCKET_PIC_FILE
chown -R www-data:www-data 12/
}

My thought to run this function in the docker container is something like this

docker exec -ti dockerwordpressmaster_mysql_1 bash -c "wordpress_production_S3_download"

but I get

bash: wordpress_production_S3_download: command not found

I have also tried to subsite the function into the variable i.e

test=$(wordpress_production_S3_download)

docker exec -ti dockerwordpressmaster_mysql_1 bash -c "$test"

but the function "variable" test only executes on the local machine and not in the Docker container like I would like.

Any help with the issue is greatly appreciated

1 Answer 1

2

You need to copy the script file containing the function into the dockerwordpressmaster_mysql_1 container and then execute it.

docker cp wordpress-script.sh dockerwordpressmaster_mysql_1:wordpress-script.js
docker exec -ti dockerwordpressmaster_mysql_1 bash -c "source wordpress-script.sh && wordpress_production_S3_download"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.