The problem of too large docker image

ask me, there is a docker image in the company, which should be transferred to several versions, installed a lot of services, and finally packaged out 17G.
is there a problem with the use of such a large image, and it is not easy to migrate? is there any way to optimize it? now there is only one tar package for export, and there is no original dockerfile.

May.10,2021

provides an idea-- first generate Dockerfile, in reverse from the docker image, and then take a look at it.
there is a library from-image" rel=" nofollow noreferrer "> dockerfile-from-image that can do this, but this library is no longer maintained. I fork changed something from-image" rel= "nofollow noreferrer" > dockerfile-from-image push to cloud.docker.com, and then you can execute the command:

docker pull fanjieqi/dockerfile-from-image:latest
alias dfimage="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock fanjieqi/dockerfile-from-image:latest"

dfimage <tag>/<image>:<version>

this can fully display the Dockerfile, of this image, but the files and folders operated by add and copy commands all have hash, so you can only guess what files and folders are operated, like this:

FROM node:9-alpine
WORKDIR /app
COPY file:7668b48cb0ef6effedbfcabe6e44cb7c70922fc63cf9e1a8fe2a259173835186 in /app
RUN npm install --production --registry=https://registry.npm.taobao.org
RUN echo -e "https://mirrors.ustc.edu.cn/alpine/latest-stable/main\nhttps://mirrors.ustc.edu.cn/alpine/latest-stable/community" > /etc/apk/repositories && apk update && apk add ca-certificates bash git openssh wget && update-ca-certificates && rm -rf /var/lib/apt/lists/*
COPY dir:1a399e39f0bccf78b41ba08e1876cbb222b21475a24c80341ff413b5a0b90b67 in /app

I hope I can help you.


go to the container and copy out the programs you need, and then rewrite dockerfile to create an image

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3dfae-e928.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3dfae-e928.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?