Up from Docker 1.13, you can use the --squash
flag.
Before version 1.13:
To my knowledge, you cannot using the Docker api. docker export
and docker import
are designed for this scenario, as you yourself already mention.
If you don't want to save to disk, you could probably pipe the outputstream of export into the input stream of import. I have not tested this, but try
docker export red_panda | docker import - exampleimagelocal:new
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…