我在Azure中托管了一个VM Linux服务器,每次提交(VSTS)时,最新的映像都需要在服务器中运行。
我创建了一个ssh文件,用于清理旧的图像和容器,登录到Azure存储库,下载最新的图像,然后运行这些图像。
编辑:某种程度上可以,但是我收到一些错误消息:
2018-07-10T13:40:20.5189780Z ##[error]WARNING! Using --password via the CLI is insecure. Use --password-stdin.
2018-07-10T13:40:20.7698990Z Login Succeeded
2018-07-10T13:40:20.8902720Z ##[error]Unable to find image 'xxx/xxx:latest' locally
2018-07-10T13:40:22.3204967Z ##[error]latest: Pulling from webapp
2018-07-10T13:40:22.3265860Z ##[error]cc1a78bfd46b: Pulling fs layer
2018-07-10T13:40:22.3324371Z ##[error]ccd8cd166265: Pulling fs layer
2018-07-10T13:40:22.3426675Z ##[error]8dadded8f35b: Pulling fs layer
2018-07-10T13:40:22.3494260Z ##[error]4ac1a8781396: Pulling fs layer
2018-07-10T13:40:22.3557213Z ##[error]358b1e620f36: Pulling fs layer
2018-07-10T13:40:22.3618978Z ##[error]9ecafc783f75: Pulling fs layer
2018-07-10T13:40:22.3680191Z ##[error]bd4678161c75: Pulling fs layer
2018-07-10T13:40:22.3740329Z ##[error]4ac1a8781396: Waiting
2018-07-10T13:40:22.3800435Z ##[error]358b1e620f36: Waiting
2018-07-10T13:40:22.3866640Z ##[error]9ecafc783f75: Waiting
2018-07-10T13:40:22.3929010Z ##[error]bd4678161c75: Waiting
2018-07-10T13:40:22.9945500Z ##[error]8dadded8f35b: Verifying Checksum
2018-07-10T13:40:23.0005648Z ##[error]8dadded8f35b: Download complete
2018-07-10T13:40:25.0963066Z ##[error]ccd8cd166265:
2018-07-10T13:40:25.1014550Z ##[error]Verifying Checksum
2018-07-10T13:40:25.1066534Z ##[error]ccd8cd166265:
2018-07-10T13:40:25.1117790Z ##[error]Download complete
2018-07-10T13:40:26.7344417Z ##[error]4ac1a8781396:
2018-07-10T13:40:26.7405020Z ##[error]Verifying Checksum
2018-07-10T13:40:26.7461298Z ##[error]4ac1a8781396:
2018-07-10T13:40:26.7516892Z ##[error]Download complete
2018-07-10T13:40:28.0278005Z ##[error]cc1a78bfd46b:
2018-07-10T13:40:28.0332847Z ##[error]Verifying Checksum
2018-07-10T13:40:28.0387928Z ##[error]cc1a78bfd46b:
2018-07-10T13:40:28.0444564Z ##[error]Download complete
2018-07-10T13:40:28.4992403Z ##[error]9ecafc783f75:
2018-07-10T13:40:28.5050705Z ##[error]Verifying Checksum
2018-07-10T13:40:28.5104450Z ##[error]9ecafc783f75:
2018-07-10T13:40:28.5159300Z ##[error]Download complete
2018-07-10T13:40:30.3861425Z ##[error]bd4678161c75:
2018-07-10T13:40:30.3913603Z ##[error]Verifying Checksum
2018-07-10T13:40:30.3969439Z ##[error]bd4678161c75:
2018-07-10T13:40:30.4024295Z ##[error]Download complete
2018-07-10T13:40:33.4125795Z ##[error]358b1e620f36:
2018-07-10T13:40:33.4178631Z ##[error]Verifying Checksum
2018-07-10T13:40:33.4237092Z ##[error]358b1e620f36:
2018-07-10T13:40:33.4290332Z ##[error]Download complete
2018-07-10T13:40:54.0405962Z ##[error]cc1a78bfd46b:
2018-07-10T13:40:54.0456335Z ##[error]Pull complete
2018-07-10T13:41:03.6392342Z ##[error]ccd8cd166265:
2018-07-10T13:41:03.6445632Z ##[error]Pull complete
2018-07-10T13:41:04.5351618Z ##[error]8dadded8f35b:
2018-07-10T13:41:04.5404186Z ##[error]Pull complete
2018-07-10T13:41:14.9043083Z ##[error]4ac1a8781396:
2018-07-10T13:41:14.9094716Z ##[error]Pull complete
2018-07-10T13:41:37.4354624Z ##[error]358b1e620f36:
2018-07-10T13:41:37.4408033Z ##[error]Pull complete
2018-07-10T13:41:37.8392568Z ##[error]9ecafc783f75:
2018-07-10T13:41:37.8449868Z ##[error]Pull complete
2018-07-10T13:41:38.6568749Z ##[error]bd4678161c75:
2018-07-10T13:41:38.6623600Z ##[error]Pull complete
2018-07-10T13:41:38.7540707Z ##[error]Digest: sha256:xxx
2018-07-10T13:41:38.8488559Z ##[error]Status: Downloaded newer image for xxx/xxx:latest
2018-07-10T13:41:39.3152654Z ##[error]docker: Error response from daemon: network idm_bridge not found.
2018-07-10T13:41:39.3216281Z ##[error]Command failed with errors on remote machine.
2018-07-10T13:41:39.5011532Z ##[section]Finishing: Run shell script on remote machine
这是我的ssh文件:
# Cleanup
docker stop $(docker ps -a -q) # Stop all containers
docker rm $(docker ps -a -q) # Delete all containers
docker rmi $(docker images -q) # Delete all images
# Download and run images
docker login xxx --username xxx --password xxx
docker run -d -p 5000:80 --network=xxx xxx/xxx