Help Center > > User Guide> Docker Basics> Creating an Image Package

Creating an Image Package

Updated at: Jun 21, 2019 GMT+08:00

This section describes how to compress a Docker image into a .tar or .tar.gz package.


  1. Log in to the Docker client as the root user.
  2. Run the following command to list images.

    docker images

    Check the name and tag of the image to be compressed.

  3. Run the following command to compress the image into a package.

    docker save [OPTIONS] IMAGE [IMAGE...]


    OPTIONS (optional): can be set to --output or -o in shorthand, indicating that the image is exported to a file before being compressed.

    The file should be in either .tar or .tar.gz.


$ docker save nginx:latest > nginx.tar
$ ls -sh nginx.tar
108M nginx.tar

$ docker save php:5-apache > php.tar.gz
$ ls -sh php.tar.gz
372M php.tar.gz

$ docker save --output nginx.tar nginx
$ ls -sh nginx.tar
108M nginx.tar

$ docker save -o nginx-all.tar nginx
$ docker save -o nginx-latest.tar nginx:latest

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?

Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel