【发布时间】:2021-03-02 22:04:52
【问题描述】:
我正在尝试使用一个脚本在 AWS 上自动化一些事情。
- 登录并关闭 docker-compose 然后删除所有图像
- 将本地文件复制到服务器
- 登录并启动 docker-compose
我的脚本是
#log in and shut down docker-compose then remove all images
ssh -i "~/Documents/AWS-Keys/mykey.pem" ubuntu@XX.XXX.XX.XXX
docker-compose down
docker image prune -f
exit
#copy local files to server
scp -r -i "~/Documents/AWS-Keys/mykey.pem" ./ubuntu ubuntu@XX.XXX.XX.XXX:/home
#log in and start docker-compose
ssh -i "~/Documents/AWS-Keys/mykey.pem" ubuntu@XX.XXX.XX.XXX
docker-compose up -d
exit
我也试过logout而不是exit,结果一样。
跑步
$ ./upload.sh
输出是:
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1038-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Mar 2 21:52:40 UTC 2021
System load: 0.07
Usage of /: 66.0% of 7.69GB
Memory usage: 36%
Swap usage: 0%
Processes: 115
Users logged in: 1
IPv4 address for xxxxxxxxxxxxxxx: XXX.XX.X.X
IPv4 address for docker0: XXX.XX.X.X
IPv4 address for eth0: XXX.XX.X.XXX
* Introducing self-healing high availability clusters in MicroK8s.
Simple, hardened, Kubernetes for production, from RaspberryPi to DC.
https://microk8s.io/high-availability
3 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
Last login: Tue Mar 2 21:51:47 2021 from XXX.XX.X.XXX
ubuntu@ip-XXX.XX.X.XXX:~$
在得到一些反馈后我也尝试了
ssh -i "~/Documents/AWS-Keys/mykey.pem" ubuntu@XX.XXX.XX.XXX
docker-compose down;
docker image prune -f;
exit
同样的结果。
【问题讨论】:
-
您尝试了错误的命令。复制并粘贴赞成的答案。
标签: amazon-web-services docker docker-compose sh