Use the operating system to create a docker base image

1. Select the minimal installation in the virtual machine or uninstall some unnecessary ones
2. #Replace the user name and group name with the user identification code and group identification code
#–exclude=/xxx Exclude files matching xxx
tar - -numeric-owner --exclude=/proc --exclude=/sys --exclude=/usr/lib/python3 --exclude=/usr/lib/python2.7 -cvf test.tar / (
by default, tar command writes the owner's username and groupname into the archive, which can cause problems, for example when restoring an archive on a different system, we might not be able to find the corresponding user or group. With the --numeric-owner option, tar command will write the owner's numeric user ID and group ID to the archive, and use these numeric IDs instead of the username or group name when restoring the archive.) 3.
Import the made test.tar into docker
cat test.tar | docker import - test:latest
4. Run and verify
docker run -it test:latest /usr/bin/sleep 100

Guess you like

Origin blog.csdn.net/qq_39412605/article/details/130889224