FROM ubuntu
ENV AWS_ACCESS_KEY_ID=xxx
ENV AWS_SECRET_ACCESS_KEY=xxx/8fMox8eNWTY51
ENV AWS_DEFAULT_REGION=us-west-2
RUN apt-get update && apt-get install -y awscli
ADD main.sh /main.sh
RUN chmod +x /main.sh
RUN /main.sh
#!/bin/bash
docker login --username=xxx--password=12xxxx
docker pull mariadb
docker pull mysql
# you can also write the credentials into the awscli configuration file.
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
aws configure set AWS_DEFAULT_REGION $AWS_DEFAULT_REGION
aws s3 cp s3://mariadbs3bucket/test4.txt /test
mysql -u sathish -pxx --host testmariadb.ci9m4obirg2u.us-west-2.rds.amazonaws.com -P 3306 --socket=TCP/IP -e "USE myDB; insert into myDB.TestTable values(50000);"
我的s3 cp命令不起作用 和Mysql命令不起作用其给出错误。我的docker文件中有什么错误吗?还是docker无法识别我的env变量? 你能帮我吗
答案 0 :(得分:0)
您需要在aws之前添加RUN命令 喜欢 运行aws cp