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