Essential Docker Command Reference

Essential Docker Command Reference

1. Searching for Images

docker search openjdk

2. Pulling Images

docker pull docker.io/library/openjdk:8
docker pull centos:7 is equivalent to docker pull registry.hub.docker.com/centos:7

3. Inspecting Image Details

docker inspect centos:7

4. Viewing Image History

docker history centos:7

5. Removing Images

docker rmi alpine:latest
docker image remove fedora:latest
This only removes the specific tag. Images with different tags but the same ID remain unaffected. For example, centos:7 and centos:latest share the same image ID, so removing latest doesn't affect centos:7.
To remove an image by ID, use the -f parameter when the image is in use.

6. Cleaning Up Images

docker image prune

7. Creating Containers

docker create -it --name java8 docker.io/library/openjdk:8<br>docker start java8<br>docker exec -it java8 /bin/bash<br>docker stop java8

8. Pausing Containers

docker pause CONTAINER_ID

9. Stopping Containers

docker stop CONTAINER_ID

10. Restarting Containers

docker restart CONTAINER_ID

11. Entering Containers

docker exec -it CONTAINER_NAME_OR_ID /bin/bash

12. Removing Containers

docker rm CONTAINER_ID

13. Viewing Statistics

docker stats<br>docker stats postgres
Displays CPU, memory, storage, network, and other resource usage statistics.

14. Copying Files

Container → Host: docker cp CONTAINER:CONTAINER_PATH HOST_PATH
docker cp java8:/app /host/path
Host → Container: docker cp HOST_PATH CONTAINER:CONTAINER_PATH
docker cp /host/path java8:/app

15. Checking File Changes

docker diff java8

16. Checking Port Mappings

docker port java8

17. Adjusting Memory Allocation

docker update --memory=8g CONTAINER_ID

18. Retrieving Container Metadata

docker inspect CONTAINER_ID | grep -i memory

Tags: docker container devops CLI Commands

Posted on Fri, 15 May 2026 01:36:31 +0000 by dagee