Docker 查看Image镜像的Dockerfile方法

1、创建测试镜像

Dockerfile:

FROM centos
LABEL maintainer="NGINX Docker Maintainers [email protected]"
RUN yum install -y nginx
RUN echo "Nginx Web: CMD defining default arguments for an ENTRYPOINT" > /usr/share/nginx/html/index.html
EXPOSE 80
CMD ["-g", "daemon off;"]
ENTRYPOINT ["/usr/sbin/nginx"]

生成镜像:

docker build -t cjavapy/nginx:v1 .

2、使用docker history

文档地址:https://github.com/cucker0/docker/blob/main/md/%E7%94%B1docker%E9%95%9C%E5%83%8F%E9%80%86%E5%90%91%E7%94%9F%E6%88%90Dockerfile.md

1)命令

docker history --format {{.CreatedBy}} --no-trunc=true 镜像 |
    sed "s,/bin/\(ba\)\?sh[ ]-c[ ]\#(nop)[ ][ ]*,,g" |
    sed "s,/bin/\(ba\)\?sh[ ]-c,RUN,g" |
    sed 's,  *&&  *, \\\n \&\& ,g' |
    tac

2)命令用法

docker history --format {{.CreatedBy}} --no-trunc=true cjavapy/nginx:v1 |
    sed "s,/bin/\(ba\)\?sh[ ]-c[ ]\#(nop)[ ][ ]*,,g" |
    sed "s,/bin/\(ba\)\?sh[ ]-c,RUN,g" |
    sed 's,  *&&  *, \\\n \&\& ,g' |
    tac

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