Tuesday, 6 March 2018

Docker Export vs Docker Save

Docker Export:
To persist docker container we need docker export command, that's why we need docker contaner-id. 
It doesn't have parent layers

Command: docker export <container-id> > /home/user1/docker_containers/Containerexport.tar

Restoring a Container:
docker import  - exampleimagelocal:new


Docker Save:
To persist docker images, we need image name to persist. It saves all parent layers.
Command:
docker save <image-name> >  /home/user1/docker_images/Imagesave.tar

Restoring an Image:
docker load <image-name> <  /home/user1/docker_images/Imagesave.tar

Dockerfile ADD vs Dockerfile Copy



ADD: ADD will do more than COPY can do.
Syntax: ADD <src> <dest>

Source can be the localfilesytem or it may also URL. It can copy and auto-extracted into the image if file in zip format.

Syntax: ADD Project/resources.tar.gz /usr/local

Now if you thought about, why not wget and curl both are capable of  getting files, but boss you have to install both tools on the container.

Copy: Copy doesn't support URL as <src> unable to download file from remote locations and unable to extract the files.
 COPY is just use for copy-files-to-container without any surprises.

Example:

Dockerfile

COPY app.sh /var/app/
ADD app.tar /var/app/