docekr history (构建历史)
简单使用
# 格式化输出,不进行简短输出
docker history mysql:5.7.25 --format "table {{.ID}}\t{{.CreatedBy}}" --no-trunc
docker history mysql:5.7.25 --format "table {{.CreatedBy}}" --no-trunc
# mysql
/bin/sh -c #(nop) CMD ["mysqld"]
/bin/sh -c #(nop) EXPOSE 3306 33060
/bin/sh -c #(nop) ENTRYPOINT ["docker-entrypoint.sh"]
/bin/sh -c ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
/bin/sh -c #(nop) COPY file:aa86b132b6a63ce8f2df8c8d76b662672060962e3252d6c86dcec28ce598e256 in /usr/local/bin/
/bin/sh -c #(nop) VOLUME [/var/lib/mysql]
/bin/sh -c { echo mysql-community-server mysql-community-server/data-dir select ''; echo mysql-community-server mysql-community-server/root-pass password ''; echo mysql-community-server mysql-community-server/re-root-pass password ''; echo mysql-community-server mysql-community-server/remove-test-db select false; } | debconf-set-selections && apt-get update && apt-get install -y mysql-server="${MYSQL_VERSION}" && rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld && chown -R mysql:mysql /var/lib/mysql /var/run/mysqld && chmod 777 /var/run/mysqld && find /etc/mysql/ -name '*.cnf' -print0 | xargs -0 grep -lZE '^(bind-address|log)' | xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/' && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf
/bin/sh -c echo "deb http://repo.mysql.com/apt/debian/ stretch mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list
/bin/sh -c #(nop) ENV MYSQL_VERSION=5.7.25-1debian9
/bin/sh -c #(nop) ENV MYSQL_MAJOR=5.7
/bin/sh -c set -ex; key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; export GNUPGHOME="$(mktemp -d)"; gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; gpg --batch --export "$key" > /etc/apt/trusted.gpg.d/mysql.gpg; gpgconf --kill all; rm -rf "$GNUPGHOME"; apt-key list > /dev/null
/bin/sh -c apt-get update && apt-get install -y --no-install-recommends pwgen openssl perl && rm -rf /var/lib/apt/lists/*
/bin/sh -c mkdir /docker-entrypoint-initdb.d
/bin/sh -c set -x && apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" && export GNUPGHOME="$(mktemp -d)" && gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && gpgconf --kill all && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && chmod +x /usr/local/bin/gosu && gosu nobody true && apt-get purge -y --auto-remove ca-certificates wget
/bin/sh -c #(nop) ENV GOSU_VERSION=1.7
/bin/sh -c apt-get update && apt-get install -y --no-install-recommends gnupg dirmngr && rm -rf /var/lib/apt/lists/*
/bin/sh -c groupadd -r mysql && useradd -r -g mysql mysql
/bin/sh -c #(nop) CMD ["bash"]
/bin/sh -c #(nop) ADD file:4fc310c0cb879c876c5c0f571af665a0d24d36cb9263e0f53b0cda2f7e4b1844 in /
参数说明
# history 命令的参数说明
[root@bigdata171 docker-compose]# docker history --help
Usage: docker history [OPTIONS] IMAGE
Show the history of an image
Options:
--format string Pretty-print images using a Go template # 格式化输出
-H, --human Print sizes and dates in human readable format (default true) # date 和 size 可读性好的输出
--no-trunc Don't truncate output # 不进行简短输出
-q, --quiet Only show numeric IDs # 只输出 id
Golang的template(模板引擎)简明教程
docker cp
简单使用
# 将 mysql docker 中的 /usr/local/bin/docker-entrypoint.sh 复制出来
docker cp docker-compose_mysql_1:/usr/local/bin/docker-entrypoint.sh ./
docker cp -L docker-compose_mysql_1:/docker-entrypoint.sh ./
参数说明
[root@bigdata171 docker-compose]# docker cp --help
Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
Copy files/folders between a container and the local filesystem
Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.
Options:
-a, --archive Archive mode (copy all uid/gid information)
-L, --follow-link Always follow symbol link in SRC_PATH # 当文件内容为链接的时候,将链接的目标进行 copy
docker build
#FROM openjdk:8-jre-alpine
FROM openjdk:8-jre
# 参数
ARG FINAL_NAME
ADD wait-for-it.sh /wait-for-it.sh
ADD ${FINAL_NAME}.jar /app.jar
ENTRYPOINT exec java $JAVA_OPTS -jar /app.jar \
--spring.profiles.active=local \
--spring.cloud.config.enabled=false \
$JAR_OPTS
# 带参数构建 build-arg
docker build --build-arg FINAL_NAME=app -t manager .
# 查看构建历史
docker history manager --format "table {{.CreatedBy}}" --no-trunc
删除 none images
docker image prune
删除停止的容器
sudo docker rm $(sudo docker ps -qf status=exited)
网友评论