Docker: How to extract the Docker image into local system

前端 未结 2 1374
余生分开走
余生分开走 2021-02-10 11:19

I want to extract the Docker image (from Ubuntu server) into my local system (Linux machine).

I run the following command

docker exec -it containername_         


        
相关标签:
2条回答
  • 2021-02-10 12:07

    You can use docker's export tool for this. docker export will output the contents of a container into a .tar file;

    $ docker export container_name > output.tar
    

    See the docker docs for more information: https://docs.docker.com/engine/reference/commandline/export/

    0 讨论(0)
  • 2021-02-10 12:13

    It depends though on what you're actually asking for. You are talking about extracting the image, but you're referring to an existing container. While jbrownwrld's answer is right in your context, if you want to extract an image, you can use docker save for that. Identify the image using:

    docker image ls
    mariadb                 10.3-bionic         92744546933d        4 days ago          343MB
    

    Then output the tar file (default format):

    docker save mariadb:10.3-bionic --output mariadb.tar
    mkdir mariadb && mv mariadb.tar mariadb && cd mariadb && tar xvf mariadb.tar
    

    There are lots of files and folders being extracted, so you had better use another directory. The folders generally correspond to the image layers.

    0 讨论(0)
提交回复
热议问题