Docker Commands

Docker ๋ช…๋ น์–ด ์ •๋ฆฌ

์ž๊พธ ์žŠ์–ด์„œ ์ •๋ฆฌ...

Create container

docker container create [์˜ต์…˜] [์ด๋ฏธ์ง€ ์ด๋ฆ„] [๋ช…๋ น] [๋งค๊ฐœ๋ณ€์ˆ˜] 

Run container

docker container run [์˜ต์…˜] [์ด๋ฏธ์ง€ ์ด๋ฆ„] [๋ช…๋ น] [๋งค๊ฐœ๋ณ€์ˆ˜]
  • -d : runs on background

Start container

docker container start [์ปจํ…Œ์ด๋„ˆ๋ช…]
  • start๋ฅผ restart ๋กœ ๋ฐ”๊พธ๋ฉด ์žฌ์‹œ์ž‘

Stop container

docker container stop [์ปจํ…Œ์ด๋„ˆ๋ช…]

Pause container

docker container pause [์ปจํ…Œ์ด๋„ˆ๋ช…]

Unpause container

docker container unpause [์ปจํ…Œ์ด๋„ˆ๋ช…]

Remove container

docker container rm [์ปจํ…Œ์ด๋„ˆ๋ช…]

Check the log

docker container logs -t webserver
  • realtime : -t ๋’ค์— -f ๋ถ™์ด๊ธฐ!

Check container stats

docker container stats [์ปจํ…Œ์ด๋„ˆ๋ช…]

Check process status

docker ps -a

Connect to container

docker exec -it [container ID] sh

List images

docker image ls

or

$ docker images
REPOSITORY                                                            TAG               IMAGE ID       CREATED        SIZE
docker/getting-started                                                latest            021a1b85e641   4 weeks ago    27.6MB
lambci/lambda                                                         build-python3.8   91a48d7f8dd1   6 weeks ago    1.95GB
alpine                                                                latest            d6e46aa2470d   2 months ago   5.57MB

Remove image(s)

docker image rm [OPTIONS] IMAGE [IMAGE ...]
  • IMAGE์—๋Š” docker image ls ๋ช…๋ น์–ด๋กœ ํŒŒ์•…ํ•œ IMAGE ID๋ฅผ ์ ์–ด์ฃผ๋ฉด ๋œ๋‹ค

Docker system prune

์•ˆ ์“ฐ๋Š” data ๋Š” ์ง€์šฐ์ž

docker network prune
docker volume prune
docker container prune
docker image prune
docker system prune  # Remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes.

Last updated