๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Server/Docker

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

by soy๋ฏธ๋‹ˆ 2021. 10. 10.

 

๐Ÿ’ก Container Command

์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰

docker start ์ปจํ…Œ์ด๋„ˆ

์ปจํ…Œ์ด๋„ˆ ์žฌ์‹คํ–‰

docker restart ์ปจํ…Œ์ด๋„ˆ

์ปจํ…Œ์ด๋„ˆ ์ค‘์ง€

docker stop ์ปจํ…Œ์ด๋„ˆ

์ปจํ…Œ์ด๋„ˆ ์ ‘์†

docker attach ์ปจํ…Œ์ด๋„ˆ

docker exec -it ์ปจํ…Œ์ด๋„ˆ /bin/bash

์ปจํ…Œ์ด๋„ˆ ์‚ญ์ œ

docker rm ์ปจํ…Œ์ด๋„ˆ

์ž‘๋™์ค‘์ธ ์ปจํ…Œ์ด๋„ˆ ์ค‘์ง€ ๋ฐ ์‚ญ์ œ

docker rm -f ์ปจํ…Œ์ด๋„ˆ

์ž‘๋™์ค‘์ธ ์ปจํ…Œ์ด๋„ˆ ํ™•์ธ

docker ps

๋ชจ๋“  ์ปจํ…Œ์ด๋„ˆ ํ™•์ธ

docker ps -a

 

 

๐Ÿ’ก Image Command

Docker Hub ์— ์˜ฌ๋ผ์™€์žˆ๋Š” ์ด๋ฏธ์ง€ ์ฐพ๊ธฐ

docker search ์ด๋ฏธ์ง€

์ด๋ฏธ์ง€ ๋‹ค์šด

docker pull ์ด๋ฏธ์ง€:ํƒœ๊ทธ

์ด๋ฏธ์ง€ ์‚ญ์ œ

docker rmi ์ด๋ฏธ์ง€

์ด๋ฏธ์ง€ ํ™•์ธ

docker images

์ด๋ฏธ์ง€ ํžˆ์Šคํ† ๋ฆฌ ์กฐํšŒ

docker history ์ด๋ฏธ์ง€:ํƒœ๊ทธ

์ด๋ฏธ์ง€/์ปจํ…Œ์ด๋„ˆ ์„ธ๋ถ€ ์ •๋ณด ์ถœ๋ ฅ

docker inspect ์ด๋ฏธ์ง€ or ์ปจํ…Œ์ด๋„ˆ

Docker Hub ์— ์ด๋ฏธ์ง€ push

docker commit <์ปจํ…Œ์ด๋„ˆ> <์ด๋ฏธ์ง€:ํƒœ๊ทธ>

docker tag <์ด๋ฏธ์ง€:ํƒœ๊ทธ> <DockerHub ์•„์ด๋””/๋ ˆํŒŒ์ง€ํ† ๋ฆฌ>

docker push <DockerHub ์•„์ด๋””/๋ ˆํŒŒ์ง€ํ† ๋ฆฌ>

Docker Hub ์—์„œ ์ด๋ฏธ์ง€ ๋‹ค์šด

docker pull <DockerHub ์•„์ด๋””/๋ ˆํŒŒ์ง€ํ† ๋ฆฌ:ํƒœ๊ทธ>

์ด๋ฏธ์ง€ ์‹คํ–‰

docker run -it --name ์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„ -p ํฌํŠธ:ํฌํŠธ-v ๋ณผ๋ฅจ ๊ฒฝ๋กœ -d ์ด๋ฏธ์ง€:ํƒœ๊ทธ

 

 

ex)

# mysql
docker run -it --name ์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„ \
-p ํฌํŠธ:ํฌํŠธ \
-v /home/tiger/db_data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=mysql๋ฃจํŠธ๋น„๋ฒˆ \
-e MYSQL_DATABASE=db์ด๋ฆ„ \
-e MYSQL_USER=mysql์œ ์ € \
-e MYSQL_PASSWORD=mysql๋น„๋ฒˆ \
-d ์ด๋ฏธ์ง€:ํƒœ๊ทธ

 

๋Œ“๊ธ€