Veröffentlicht am Samstag, 13 Mai 2023 Docker: Befehlssammlung Kategorie Sonstiges Eine Liste an nützlichen Befehlen von Docker - wird stetig ergänzt - letzter Stand: 15.06.2023docker ps # Lists containers running docker ps -a # Lists containers (and tells you which images they are spun from) docker rm <container_id> # Removes a stopped container -f <container_id> # Forces the removal of a running container (uses SIGKILL) docker rmi <image_id> # Removes an image # Will fail if there is a running instance of that image i.e. container -f <image_id> # Forces removal of image even if it is referenced in multiple repositories, i.e. same image id given multiple names/tags # Will still fail if there is a docker container referencing image docker build . # Builds Docker images from a Dockerfile and a “context”, in current path docker build $PATH # Builds Docker images from a Dockerfile and a “context”, in $PATH -t, --tag stringArray # Name and optionally a tag (format: "name:tag") docker run # Create and run a NEW container from an image -i # Run interactive -t # Run with terminal -it # Run with interactive terminal -p LOCAL_PORT:EXPOSE_PORT # Run with port LOCAL_PORT EXPOSE_PORT (CONTAINER_PORT) -d # Deattached mode --rm # Automatically remove the container when it exits --name string # Assign a name to the container -v # Bind mount a volume /app/data # Anonymous Volume data:/app/data # Named Volume /path/to/code:/app/code # Bind Mount docker stop # Stop one or more running containers docker start # Start one or more running containers -a, --attach # Attach STDOUT/STDERR and forward signals -i, --interactive # Attach container's STDIN docker tag # Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE -> SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] docker tag OLD_NAME NEW_NAME # Rename docker images # Lists images docker image inspect # Display detailed information on one or more images docker image rm # Remove one or more images docker image prune # Remove unused images docker logs # Fetch the logs of a container -f # Follow log output docker cp # Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|- docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH docker login #Log in to a registry at https://hub.docker.com docker logout docker volume # Manage volumes ls # List volumes rm # Remove one or more volume prune # Remove all unused local volumes create # Create a volume docker history <IMAGE> # Show the history of an imageSiehe dazu auch:https://docs.docker.com/go/guides/ und https://docs.docker.com/engine/reference/builder/ und https://docs.docker.com/engine/reference/run/