#!/bin/bash environment=$1 version=$2 echo "环境变量为${environment},版本为$version!" if [[ ${environment} == 'production' ]]; then echo "开始远程构建容器" exit 0 elif [[ ${environment} == 'test' ]]; then echo "开始在测试环境远程构建容器" docker stop amqp_test || true docker rm amqp_test || true docker rmi -f $(docker images | grep 139.224.254.18:5000/amqp_test | awk '{print $3}') docker pull 139.224.254.18:5000/amqp_test:$version docker run -d -e environment=test -v /home/data/amqp_test/log:/var/amqp/logs --name amqp_test 139.224.254.18:5000/amqp_test:$version; #删除产生的None镜像 docker rmi -f $(docker images | grep none | awk '{print $3}') docker ps -a fi