#!/bin/bash
if [[ "$(docker images -q chenzj/dfimage:latest 2> /dev/null)" == "" ]]; then
docker pull chenzj/dfimage
fi
read -e -p "Enter Image ID: " IMAGE_ID
if grep -q dfimage /etc/profile;
then
:
else
echo "" >> /etc/profile
echo alias dfimage="'docker run -v /var/run/docker.sock:/var/run/docker.sock --rm chenzj/dfimage'" >> /etc/profile
source /etc/profile
fi
docker run -v /var/run/docker.sock:/var/run/docker.sock --rm chenzj/dfimage $IMAGE_ID > Dockerfile1
docker history --no-trunc $IMAGE_ID | tac | tr -s ' ' | cut -d " " -f 5- | sed 's,^/bin/sh -c #(nop) ,,g' | sed 's,^/bin/sh -c,RUN,g' | sed 's, && ,\n & ,g' | sed 's,\s*[0-9]*[\.]*[0-9]*[kMG]*B\s*$,,g' | head -n -1 > Dockerfile2
if [[ "$(docker images -q chenzj/dfimage:latest 2> /dev/null)" == "" ]]; then
docker pull chenzj/dfimage
fi
read -e -p "Enter Image ID: " IMAGE_ID
if grep -q dfimage /etc/profile;
then
:
else
echo "" >> /etc/profile
echo alias dfimage="'docker run -v /var/run/docker.sock:/var/run/docker.sock --rm chenzj/dfimage'" >> /etc/profile
source /etc/profile
fi
docker run -v /var/run/docker.sock:/var/run/docker.sock --rm chenzj/dfimage $IMAGE_ID > Dockerfile1
docker history --no-trunc $IMAGE_ID | tac | tr -s ' ' | cut -d " " -f 5- | sed 's,^/bin/sh -c #(nop) ,,g' | sed 's,^/bin/sh -c,RUN,g' | sed 's, && ,\n & ,g' | sed 's,\s*[0-9]*[\.]*[0-9]*[kMG]*B\s*$,,g' | head -n -1 > Dockerfile2
No comments:
Post a Comment