Skip to content

Instantly share code, notes, and snippets.

@daluu
Last active August 1, 2023 19:46
Show Gist options
  • Save daluu/ba1ce114e2e78cdf7eae183d39a0075f to your computer and use it in GitHub Desktop.
Save daluu/ba1ce114e2e78cdf7eae183d39a0075f to your computer and use it in GitHub Desktop.
Docker notes
docker system prune --volumes
docker run -u`id -u`:`id -g` -v $(pwd):/user/project -v ~/.aws:/user/.aws -v ~/.npmrc:/user/.npmrc -w /user/project -it --entrypoint /bin/bash circleci/node:12
# get compressed size of docker images (after they're pulled locally)
docker save image-name:latest > sizetest.tar
gzip sizetest.tar
ls -lh sizetest.tar.gz
# see https://github.com/docker/docker/issues/1143
export DOCKERHOST="$(ifconfig en0 inet | grep "inet " | awk -F'[: ]+' '{ print $2 }')"
----
#!/bin/sh -x
# http://stackoverflow.com/questions/33995276/no-space-left-on-device-while-installing-a-tar-using-docker
# with docker 1.13
#docker system prune
docker stop $(docker ps -a -q) | xargs docker rm
#docker rm $(docker ps -a -q)
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
#export DOCKER_HOST='unix:///Users/USERNAME/.local/share/containers/podman/machine/podman-machine-default/podman.sock'
# useful only for Mac OS Silicon M1,
# still working but useless for the other platforms
docker() {
if [[ `uname -m` == "arm64" ]] && [[ "$1" == "run" || "$1" == "build" ]]; then
/usr/local/bin/docker "$1" --platform linux/amd64 "${@:2}"
else
/usr/local/bin/docker "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment