DEV Community

Beau
Beau

Posted on

Very Basic Docker Commands Cheat Sheet

If you ever needed a quick list of Docker commands, here you go..

1. Check that Docker is installed

docker --version
Enter fullscreen mode Exit fullscreen mode

Shows the installed Docker version.

2. Run your first container

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Pulls the official test image (if needed) and runs it. You should see a “Hello from Docker!” message.

3. See running containers

docker ps
Enter fullscreen mode Exit fullscreen mode

Lists containers that are currently running.

Use docker ps -a to also show stopped ones.

4. See downloaded images

docker images
Enter fullscreen mode Exit fullscreen mode

Shows every image on your machine (name, tag, size, ID).

5. Stop a running container

docker stop CONTAINER_ID
Enter fullscreen mode Exit fullscreen mode

Gracefully stops a container. Get the ID from docker ps.

6. Remove a stopped container

docker rm CONTAINER_ID
Enter fullscreen mode Exit fullscreen mode

Deletes a container that is already stopped.

7. Force stop and remove

docker rm -f CONTAINER_ID
Enter fullscreen mode Exit fullscreen mode

Force-stops the container (if it’s still running) and removes it in one step.

Top comments (0)