본문 바로가기
+ Application/Docker

[Docker] Docker-compose 중지 방법

by :: Teacher :: 2020. 1. 5.
728x90
반응형

docker-compose를 사용하여 시스템을 구동하고, 중지 할 수 있다. 

그 중 중지 방법에는 2가지 방법이 존재 하고 있다. 

docker-compose stop / docker-compose down 와 같이 방법이 존재하며 아래 내용을 통해서 차이점을 살펴보자.

1. docker-compose stop

stop 으로 중지시에는 아래와 같이 docker-compose를 통해서 구동한 서비스에 대해서 중지가 되며, 
기존 서비스 구동 후 설정한 내용에 대해서 남아 있게 된다. 

결국 Config, DB와 같은 시스템의 경우 잠시 서비스만 중지 되며 해당 컨테이너 내부에 데이터, 설정등은 변경 사항이 없다.

$ docker-compose ps
             Name                           Command               State           Ports
------------------------------------------------------------------------------------------------
anchore_anchore-db_1             docker-entrypoint.sh postgres    Up      5432/tcp
anchore_engine-analyzer_1        /docker-entrypoint.sh anch ...   Up      8228/tcp
anchore_engine-api_1             /docker-entrypoint.sh anch ...   Up      0.0.0.0:8228->8228/tcp
anchore_engine-catalog_1         /docker-entrypoint.sh anch ...   Up      8228/tcp
anchore_engine-policy-engine_1   /docker-entrypoint.sh anch ...   Up      8228/tcp
anchore_engine-simpleq_1         /docker-entrypoint.sh anch ...   Up      8228/tcp



$ docker-compose stop
Stopping anchore_engine-simpleq_1       ... done
Stopping anchore_engine-api_1           ... done
Stopping anchore_engine-policy-engine_1 ... done
Stopping anchore_engine-analyzer_1      ... done
Stopping anchore_engine-catalog_1       ... done
Stopping anchore_anchore-db_1           ... done



$ docker-compose ps
             Name                           Command                State     Ports
----------------------------------------------------------------------------------
anchore_anchore-db_1             docker-entrypoint.sh postgres    Exit 0
anchore_engine-analyzer_1        /docker-entrypoint.sh anch ...   Exit 137
anchore_engine-api_1             /docker-entrypoint.sh anch ...   Exit 137
anchore_engine-catalog_1         /docker-entrypoint.sh anch ...   Exit 137
anchore_engine-policy-engine_1   /docker-entrypoint.sh anch ...   Exit 137
anchore_engine-simpleq_1         /docker-entrypoint.sh anch ...   Exit 137

 

2. docker-compose down

down 으로 중지시에는 아래와 같이 docker-compose를 통해서 구동한 서비스에 대해서 중지가 되며, 
구동시 사용된 컨네이터에 대해서도 제거가 된다.

결국 컨테이너가 제거됨에 따라, 처음 구성과 같이 초기화 상태가 된다.

$ docker-compose ps
             Name                           Command               State           Ports
------------------------------------------------------------------------------------------------
anchore_anchore-db_1             docker-entrypoint.sh postgres    Up      5432/tcp
anchore_engine-analyzer_1        /docker-entrypoint.sh anch ...   Up      8228/tcp
anchore_engine-api_1             /docker-entrypoint.sh anch ...   Up      0.0.0.0:8228->8228/tcp
anchore_engine-catalog_1         /docker-entrypoint.sh anch ...   Up      8228/tcp
anchore_engine-policy-engine_1   /docker-entrypoint.sh anch ...   Up      8228/tcp
anchore_engine-simpleq_1         /docker-entrypoint.sh anch ...   Up      8228/tcp



$ docker-compose down
Stopping anchore_engine-simpleq_1       ... done
Stopping anchore_engine-api_1           ... done
Stopping anchore_engine-policy-engine_1 ... done
Stopping anchore_engine-analyzer_1      ... done
Stopping anchore_engine-catalog_1       ... done
Stopping anchore_anchore-db_1           ... done
Removing anchore_engine-simpleq_1       ... done
Removing anchore_engine-api_1           ... done
Removing anchore_engine-policy-engine_1 ... done
Removing anchore_engine-analyzer_1      ... done
Removing anchore_engine-catalog_1       ... done
Removing anchore_anchore-db_1           ... done
Removing network anchore_default



$ docker-compose ps
Name   Command   State   Ports
------------------------------

 

서비스 중지가 필요한 경우 2가지 중지 방법에 대해서 잘 이해하고 선택하여 처리가 필요하다.

서비스 형태, 상황에 맞게 선택하여 중지 하도록 하자.

 

728x90
반응형

댓글


loading