Last active
January 12, 2023 02:41
-
-
Save adarshaacharya/d61fe4d08a60169d475cec7d403b0e6d to your computer and use it in GitHub Desktop.
Docker Commands
This file contains 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
##### Pull repo from Docker hub | |
`docker pull <image>` | |
##### List Docker images | |
`docker images` | |
## Docker build | |
docker build -f Dockerfile -t hobnob/crm-v1 . | |
##### List Docker running containers | |
`docker ps` | |
##### List all docker running and non running containers | |
`docker ps -a` | |
##### Run a image as container | |
`docker run -it <image>:<tag> [/bin/bash]` | |
* -d for daemon | |
* --name for name | |
* -p to expose port | |
eg: docker run --rm -p 2222:3000 -it my-node-app(image name) | |
##### Stop docker container gracefully | |
`docker stop <container id|name>` | |
##### Start docker container | |
`docker start <container id>` | |
##### kill container immediately | |
`docker kill <container id>` | |
##### Output logs from docker container proxying stdout | |
` docker logs <container id>` | |
##### exec command on docker container | |
`docker exec -it ada2e82a3d3e(containerid) sh` | |
###### Search images in docker hub | |
`docker search <search term>` | |
###### change the name that has been randomly generated for the container | |
`docker rename <current_container_name> <new_container_name>` | |
###### take a peek inside our containers | |
` docker stats <container_name>` | |
###### list of all running processes inside the container | |
` docker top <container_name>` | |
###### Remove container | |
`docker rm <container>` | |
* -v to remove with volume | |
###### Remove image | |
` docker rmi <image>` | |
## Remove all images with cache | |
` docker system prune -a` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment