根据docker image 解析出Dockerfile

两种方式:

第一种 使用docker history 

docker history  *docker image的名字*  --format {{.CreatedBy}} --no-trunc=true $DockerImage |sed "s/\/bin\/sh\ -c\ \#(nop)\ //g"|sed "s/\/bin\/sh\ -c/RUN/g" | tac

方法二:

使用whaler

GitHub - P3GLEG/Whaler: Program to reverse Docker images into Dockerfiles

wget https://github.com/P3GLEG/Whaler/archive/refs/heads/master.zip
unzip master.zip
vim Dockerfile

编写Dockerfile

FROM golang:1.14.4 AS builder
ENV GOPROXY=https://goproxy.cn


ADD . /root/whaler_build
WORKDIR /root/whaler_build
RUN export CGO_ENABLED=0 && go build .
RUN cp whaler /root/whaler

FROM alpine:3.12.0
WORKDIR /root/
COPY --from=builder /root/whaler .
ENTRYPOINT ["./whaler"]

编译镜像

docker build -t whaler:latest .
alias whaler="docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock:ro pegleg/whaler"

解析镜像:

whaler nginx:1.16

你可能感兴趣的:(docker,java,容器)