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_or_ID /bin/bash
I am able to view image by using this command, but I am unable to get this image into my local system.
You can use docker's
export
tool for this.docker export
will output the contents of a container into a .tar file;See the docker docs for more information: https://docs.docker.com/engine/reference/commandline/export/
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:
Then output the tar file (default format):
There are lots of files and folders being extracted, so you had better use another directory. The folders generally correspond to the image layers.