Docker

What and Why?

Abbreviate

Installation

Info

For all platform, please check the official guide

P/S: On MacOS I recommend using Orbstack that is native MacOS and free for Personally uses. It’s really light, fast and simple way to use Linux Machines.

Troubleshooting

Some usually commands

Multi-column

Images

# list images on the host
docker images
# check image's info
docker inspect <image_id>
# where are images stored?
docker info
# normally: /var/lib/docker
Container

# list running container
docker ps
docker ps -a # all (include stopped)
# check log
docker container logs <container_id>
# get ip address
docker inspect <container_id> | grep IPAddress

Others

Terminal window
# ram & cpu usages
docker stats
docker stats <container_name|container_id>
# get ip address
docker inspect <container_name|container_id> | grep IPAddress

Attach/Start/Stop

We can use sometimes interchangeable between <container_id> and <container_name>.

Terminal window
# start container
docker start <container_name|container_id>
# start and enter the container
docker start -d <container>
Terminal window
# stop container
docker stop <container_name|container_id>
# stop all container
docker stop ${docker ps -a -q}
Terminal window
# entering the running container (no attach)
docker exec -it <container_name|container_id> /bin/bash