[Docker] Docker Image and Container

2024. 3. 21. 14:19ใ†ComputerScience/DockerKubernetes

 

 

 

 

 

Docker ๐Ÿณ

https://velog.io/@geunwoobaek/์ปจํ…Œ์ด๋„ˆ-๋ฐ-๋„์ปค-๊ฐœ๋…์ •๋ฆฌ

 

 

 

 

 

# Documentation

https://docs.docker.com/reference/cli/docker/image/

https://docs.docker.com/reference/cli/docker/container/

 

docker container

 

docs.docker.com

 

 

 

 

 

# Ubuntu๋ฅผ pull ํ•ด์˜ค์ž 

docker image ls 

docker container ls 

docker pull ubuntu 

 

# ๋„์ปค์•ผ ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰

docker container run -it -d --rm --name ubuntuos ubuntu:latest 

-d ์„œ๋ฒ„์ฒ˜๋Ÿผ ๋Œ์•„์ค˜

--rm ๋๋‚˜๋ฉด ์ง€์›Œ๋ผ

-it ํ‚ค๋ณด๋“œ ์ž…์ถœ๋ ฅ, ๋‚ด๊ฐ€ ์žฅ์•…ํ• ๊ฑฐ์•ผ

์ด๋ฆ„์„ ๋‚œ์ˆ˜๊ฐ€ ์•„๋‹Œ ubuntuos๋กœ ๋ถ™์—ฌ์ค„ ์ˆ˜ ์žˆ๋‹ค

 

# ์šฐ๋ถ„ํˆฌ์˜ bash 

docker exec -it ubuntuos /bin/bash 

exit ํ•˜๋ฉด ์ปจํ…Œ์ด๋„ˆ์—์„œ ๋‚˜์˜จ๋‹ค

 

# ๋„์ปค์•ผ ์ปจํ…Œ์ด๋„ˆ๋“ค ๋ณด์—ฌ์ค˜ 

docker container ls

 

# ๋„์ปค์•ผ ์ด๋ฏธ์ง€๋“ค์„ ๋ณด์—ฌ์ค˜

docker image ls

 

# ๋„์ปค์•ผ ์šฐ๋ถ„ํˆฌ ์ปจํ…Œ์ด๋„ˆ ์ง€์›Œ์ค˜

docker container stop ubuntuos

—rm์˜ ํšจ๊ณผ (exit ๋˜์ž๋งˆ์ž ์ง€์šด ๊ฒƒ)

 

# ๋„์ปค์•ผ ์ด๋ฏธ์ง€ ์ง€์›Œ์ค˜ 

docker image rm ubuntu:latest

-f ๋Š” ๊ฐ•์ œ ์ข…๋ฃŒ (force)

// ex) ์ปจํ…Œ์ด๋„ˆ ๋Œ๊ณ  ์žˆ์„ ๋•Œ -f, —force

* ์ด๋ฏธ์ง€ -> ์ปจํ…Œ์ด๋„ˆ run -> ์ปจํ…Œ์ด๋„ˆ rm -> ์ด๋ฏธ์ง€ rm 

 

 

 

 

 

command๋ฅผ ํ†ตํ•ด ์šฐ๋ถ„ํˆฌ๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ์„ค์น˜ํ•˜๋Š” ๋ชจ์Šต

 

 

 

 

 

Docker Desktop์„ ํ†ตํ•ด GUI๋กœ ๊ฐ„ํŽธํ•˜๊ฒŒ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ทธ์น˜๋งŒ ์ปค๋งจ๋“œ๋ผ์ธ์ด ๋” ๋ฉ‹์žˆ๋‹ค ^^,

 

 

 

 

 

'ComputerScience > DockerKubernetes' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Docker] M1 Docker-machine Error, Ubuntu ์„ค์น˜  (0) 2024.04.17
[Docker] CI/CD with Jenkins  (0) 2024.04.16
[Docker] Docker Compose  (0) 2024.04.08
[Docker] Dockerfile build & image push  (0) 2024.04.01
[Docker] Getting started with Docker  (0) 2024.03.28