Extract code and configuration files from the docker image

directly on the shell script

function getjavafile()
{
	docker run -d -i -t 192.168.2.208:5000/$TYPE/$1:$2 /bin/bash
	echo "Create Contianer Success"
	Contianer_ID=`docker ps | awk '{if($2=="192.168.2.208:5000/'$TYPE'/'$1':'$2'"){print $1;}}'`
	docker cp $Contianer_ID:$3 $4
	docker cp $Contianer_ID:$5 $6
	echo "Cp File Success"
	docker stop $Contianer_ID && docker rm $Contianer_ID
	echo "Stop And Rm Contianer Success"
}


getjavafile frontend $frontend_num /opt/tingyun/frontend/webapps/frontend/webapp $WORK_PATH/frontend/webapps/frontend/ /opt/tingyun/frontend/webapps/frontend/conf $WORK_PATH/frontend/webapps/frontend/

 

 

A function is written here, mainly to create and copy the container through docker cp and then delete the container.

There is a pit here that docker cp cannot copy the files inside and rename them at the same time, so I can only copy the conf directory inside and rename it to the desired name

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326175245&siteId=291194637