Skip to content

Instantly share code, notes, and snippets.

@neogeogre
Last active July 20, 2023 11:40
Show Gist options
  • Save neogeogre/7543bd04e896c0cb1049f3f2313d0e92 to your computer and use it in GitHub Desktop.
Save neogeogre/7543bd04e896c0cb1049f3f2313d0e92 to your computer and use it in GitHub Desktop.
Docker samples, install without sudo and remove root to generated files
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world
docker pull osgeo/gdal:ubuntu-full-3.1.2
# Allow to use without sudo:
sudo gpasswd -a $USER docker
sudo groupadd docker
sudo service docker restart
sudo service docker.io restart
# Run container without root output:
docker run --user $(id -u):$(id -g) -t --rm \
-v /tmp:/workspace/geometry \
--net host \
repository.io/myDocker:1.0.4 \
/workspace/geometry/shape.geojson
# Delete all containers:
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
# Delete <none> images
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
# Clear cache
docker system prune -a
# Enter in an image
docker run -it --entrypoint /bin/sh gcr.io/kaniko-project/executor:debug
# Enter in an image and bypass entrypoint
docker run -it --entrypoint /bin/sh my-image
# Connect to the localhost of the host from the inside of a container
# Use --network="host" in your docker run command, then 127.0.0.1 in your docker container will point to your docker host.
# https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment