Skip to main content

Devop Snippets

Docker

Export image file system

docker run is a two step process: docker create + docker start, so utilizing docker create command will create the folder but won't actually start the container.

container_id=$(docker create postgres)
docker export ${container_id} -o postgres.tar.gz

In contrast, docker export command only works on a running container.

Another alternative is docker build:

echo 'FROM postgres' > Dockerfile
docker build -o temp .
ls -l temp

Remove all containers

docker rm $(docker ps -aq)