์ด ์์
์ ์ํํ ์ ์์ผ๋ฉด ์ ์ฉํ ๊ฒ์
๋๋ค.
docker-compose build service1 service2 --no-cache
๋ฐฉ๊ธ ๊ตฌ๋ฌธ์ด ๋ค์๊ณผ ๊ฐ๋ค๋ ๊ฒ์ ๊นจ๋ฌ์์ต๋๋ค.
docker-compose build --no-cache service1 service2
๋๋ ์ด๊ฒ์ ์ฐพ๊ณ ์์๋ค !!
๋ค์์ ์์ฑ ์คํ์ ๋ค์ ์์ฑํ๋ ๊น๋ํ ๋ฐฉ๋ฒ์ ๋๋ค.
cd(์์ฑ ๋๋ ํฐ๋ฆฌ๋ก)
docker-compose rm --all &&
docker-compose pull &&
docker-compose build --no-cache &&
docker-compose up -d --force-recreate &&
๋ง์ด ๋ฉ๋๊น? ๋๋ ์ฌ๊ธฐ์์ ๋ชจ๋ฒ ์ฌ๋ก๋ฅผ ์ฐพ๊ณ ์์ต๋๋ค :)
+1
--force-recreate๊ฐ ํ์ํฉ๋๊น?
+1
--force-recreate
๊ฐ ์ต์ ์ ์ ํ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
๋ชจ๋ ์ปจํ
์ด๋๊ฐ ๋ฐฉ๊ธ ์ ๊ฑฐ๋์์ผ๋ฏ๋ก --force-recreate
๋ ํ์ํ์ง ์์ต๋๋ค.
๋ชจ๋ ๊ฒ์_ ์ง์ฐ๊ณ ์ถ๋ค๋ฉด down
๊ฐ rm
๋ณด๋ค ๋ซ์ต๋๋ค. ๋ณผ๋ฅจ๊ณผ ๋คํธ์ํฌ๋ ์ ๊ฑฐํ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค.
$ docker-compose down -h
Stops containers and removes containers, networks, volumes, and images
created by `up`.
By default, the only things removed are:
- Containers for services defined in the Compose file
- Networks defined in the `networks` section of the Compose file
- The default network, if one is used
Networks and volumes defined as `external` are never removed.
Usage: down [options]
Options:
--rmi type Remove images. Type must be one of:
'all': Remove all images used by any service.
'local': Remove only images that don't have a custom tag
set by the `image` field.
-v, --volumes Remove named volumes declared in the `volumes` section
of the Compose file and anonymous volumes
attached to containers.
--remove-orphans Remove containers for services not defined in the
Compose file
๋๋ ์ด๊ฒ์ 3 ๊ฐ์๋ถํฐ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ ๋ด ์๊ตฌ ์ฌํญ์ ์ ํฉํฉ๋๋ค.
์ ๊ฑฐํ๊ณ ์ถ์ง ์์: ๋คํธ์ํฌ, ๋ณผ๋ฅจ ๋ฐ ์ด๋ฏธ์ง
echo && echo "PikWi says: docker-compose stop" && \
docker-compose stop && \
echo "PikWi says: docker-compose rm ..." && \
docker-compose rm -f --all && \
echo "PikWi says: docker-compose pull" && \
docker-compose pull && \
echo "PikWi says: docker-compose build ..." && \
docker-compose build --no-cache && \
echo "PikWi says: docker-compose up ..." && \
docker-compose up -d --force-recreate --remove-orphans
๋ ์งง๊ฑฐ๋ ๊นจ๋ํ ๊ฒ์ ์ฌ์ฉํ๊ฒ ๋์ด ๊ธฐ์ฉ๋๋ค. ๋๋ ๋ชจ๋ ๋ฒ ์คํธ ํ๋ํฐ์ค์ ๋๋ค :)
๊ฑด๋ฐฐ!
--no-cache๊ฐ ์๋ํ์ง ์์ต๋๋ค.... ๋์์ ๋ฌด์์ ๋๊น --force-rebuild๋ ๊ณ์ํด์ ์บ์๋ฅผ ์ฌ์ฉํฉ๋๋ค :(
@julianfrank --no-cache does not work
๊ฐ ๋ฌด์์ ์๋ฏธํ๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ง๋ง ์๋ง๋ ๋ค์๊ณผ ๊ฐ์ด ์คํํ ๊ฒ์
๋๋ค.
docker-compose build SERVICE_NAME --no-cache
์ค์ ๋ก docker-compose build --no-cache SERVICE_NAME
์ฌ์ผ ํ ๋?
๋น๋๋๋ ์ฌ๋ฌ ์๋น์ค์์ ๋จ๊ณ๊ฐ ๋์ผํ๋ฉด ์คํฌ๋ฆฝํธ์์ ์ด์ ์ ๋น๋ํ ์ปจํ ์ด๋์ ์บ์๋ฅผ ๊ณ์ ์ฌ์ฉํฉ๋๋ค... ์บ์๋ฅผ ์ฌ์ฉํ๊ณ ์์๋ฅผ ๋ณ๊ฒฝํ์ฌ ์บ์๋ฅผ ๊ฐ์ ๋ก ๊ฑด๋๋ฐ๊ณ ์ถ์ ๋ ๋์ผํ ๋จ๊ณ๋ฅผ ์ฌ์ฉํ๋ ๋์์ ์ฐพ์์ต๋๋ค. ์ฉ๋ฒ...
์บ์์ ์ํด ๋ง์ณค๊ณ ๋์ ์บ์๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ ๋์ปค ํ์ผ์ ์ ๋ช ๋ น์ ์ฝ์ ํ์ฌ ์บ์ ๋ ์ด์ด ๊ฐฑ์ ์ ๊ฐ์ ๋ก ์ถ์ฒํ๊ณ ๋์ปค์ ์บ์ ์ฒ๋ฆฌ์ ๋ฆฌํฉํ ๋ง์ด ํ์ํฉ๋๋ค... ๋๋ ์ค์ ๋ก ์บ์ ๋ ์ด์ด๋ฅผ ์ ๋ฆฌํ๋ ์์
์ค์ ๋ก๋ ์๋ํ์ง ์์ต๋๋ค ...
์๋น์ค์ ๋ํ Dockerfile์์ ๋ชจ๋ ๋ณ๊ฒฝ์ ์ํํ ์ ์์ผ๋ฉฐ docker-compose build --no-cache
์๋ ๋ฐ์๋์ง ์์ต๋๋ค.
docker-compose up -d --build --no-deps web
๋ docker-compose.yml์์ "web"์ด๋ผ๋ ์๋น์ค์ ๋ํ ์ปจํ
์ด๋๋ฅผ ๋ค์ ๋น๋ํฉ๋๋ค. ์ฌ๊ตฌ์ถ์ด ์๋ฃ๋๋ฉด ์ง์ ๋ ์ปจํ
์ด๋๋ฅผ ๋ค์ ์์ํฉ๋๋ค.
--no-deps
๋ ๋ช
๋ น์ ์ง์ ๋ ์๋น์ค ์ด๋ฆ์ผ๋ก ์ฌ๊ตฌ์ถ์ ์ ํํฉ๋๋ค.
๋ํ ์ด ๋ช ๋ น์ ํ์ผ์ ์ปจํ ์ด๋์ ๋ณต์ฌํ๊ณ ์๊ณ ๋ณต์ฌํ ํ์ผ ์ค ํ๋๊ฐ ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ(์: requirements.txt) ์ปจํ ์ด๋๋ฅผ ๋ค์ ๋น๋ํฉ๋๋ค.
์ฐธ๊ณ ๋ก
docker-compose up --force-recreate --build
up ๋ช
๋ น์ --no-cache ์ต์
์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
force-recreate๊ฐ ์ด ์ต์
์ ์ฌ์ฉํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋ด๊ฐ ํ๋ ธ๋ค๋ฉด ์ ๋ฅผ ์์ ํ์ญ์์ค!
๊ทธ๋์ ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ ๋ด๊ฐ ์ด๊ฒ์ํ๋ ๊ฒ์ ๋๋ค ...
์ปจํ
์ด๋ ๋ฐ ์ด๋ฏธ์ง ์ ๊ฑฐ > ๋น๋ ์บ์ ์์ด ์ด๋ฏธ์ง ๋น๋ > docker-compose up detached > ๋ก๊ทธ ์ถ์ (๋ฐ๋ผ์ ctrl+c
๋ฅผ ์ฌ์ฉํ ์ ์์)
docker-compose build --force-rm --no-cache && docker-compose up --detach && docker-compose logs -f
์๋์ฐ:
docker-compose build --force-rm --no-cache ; docker-compose up --detach ; docker-compose logs -f
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ฐฉ๊ธ ๊ตฌ๋ฌธ์ด ๋ค์๊ณผ ๊ฐ๋ค๋ ๊ฒ์ ๊นจ๋ฌ์์ต๋๋ค.
docker-compose build --no-cache service1 service2