Skip to content
Matt Harley edited this page Oct 29, 2015 · 6 revisions

Reducing an image size

# from http://tuhrig.de/flatten-a-docker-container-or-image/
docker export <CONTAINER ID> | docker import - some-image-name:latest
  • A Docker image can be saved to a tarball and loaded back again. This will preserve the history of the image.
# save the image to a tarball
docker save <IMAGE NAME> > /home/save.tar
 
# load it back
docker load < /home/save.tar
  • A Docker container can be exported to a tarball and imported back again. This will not preserve the history of the container.
# export the container to a tarball
docker export <CONTAINER ID> > /home/export.tar
 
# import it back
cat /home/export.tar | docker import - some-name:latest

Enable the Docker API

# Something like this...
sudo su -c "echo \"DOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'\" >> /etc/default/docker"

Resources

Credits