Linux - 批处理命令

1.新建批处理文件,文件后缀名为".sh" -- 新建一个docker批处理的文件

touch docker_batch_test.sh

2.在批处理文件中添加执行脚本


#!/bin/sh
echo "====================images - remove===================="
docker rmi -f {your_image_name}
echo "====================images - build===================="
docker build -t {your_image_name} /root/release/{your_image_path}
echo "====================container - remove===================="
docker rm -f {your_container_name}
echo "====================container - run===================="
docker run --name {your_container_name} -p 8081:8081 -itd -v /etc/localtime:/etc/localtime:ro -v /ect/timezone:/etc/timezone:ro {your_image_path}

//注意事项:
批处理文件第一行必须是#!/bin/sh

3.执行

sh docker_batch_test.sh

附加.脚本添加执行权限

chmod 777 docker_batch_test.sh
上一篇:【面试虐菜】—— JAVA面试题(1)


下一篇:base编程语法之一