Created
January 10, 2023 22:56
-
-
Save petergi/6609244cf2baae64ef3e41636e0f7f5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # To start the docker daemon: | |
| docker -d | |
| # To build a docker image: | |
| docker build -t <image-tag-name> <path-of-Dockerfile> | |
| # To start a container with an interactive shell: | |
| docker run -ti <image-name> /bin/bash | |
| # To "shell" into a running container (docker-1.3+): | |
| docker exec -ti <container-name> bash | |
| # To inspect a running container: | |
| docker inspect <container-name> (or <container-id>) | |
| # To get the process ID for a container: | |
| docker inspect --format {{.State.Pid}} <container-name-or-id> | |
| # To list (and pretty-print) the current mounted volumes for a container: | |
| docker inspect --format='{{json .Volumes}}' <container-id> | python -mjson.tool | |
| # To copy files/folders between a container and your host: | |
| docker cp foo.txt mycontainer:/foo.txt | |
| # To list currently running containers: | |
| docker ps | |
| # To list all containers: | |
| docker ps -a | |
| # To remove all stopped containers: | |
| docker rm $(docker ps -qa) | |
| # To list all images: | |
| docker images | |
| # To remove all untagged images: | |
| docker rmi $(docker images | grep "^<none>" | awk '{print $3}') | |
| # To remove all volumes not used by at least one container: | |
| docker volume prune | |
| # To save image as tar archive: | |
| docker save -o <archive-name>.tar <image-name> | |
| # To restore image from a saved tar archive: | |
| docker load -i <archive-name>.tar | |
| # To remove an image image: | |
| docker image rm <image-name-or-id> | |
| # To tag an image: | |
| docker image tag <image-name>:<tag-name> <image-name>:<new-tag-name> | |
| # To login into hub.docker.com: | |
| docker login | |
| # To push a docker image into dockerhub repository: | |
| docker push <image-name>:<image-tag-name> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment