도커 (3) 썸네일형 리스트형 외부에서 Docker 컨테이너로 명령어 날리는 방법 간혹 Docker를 사용하다보면, 컨테이너 내부에서 리눅스 명령어를 실행해야 하는 일이 있다. 이 때, 직접 Docker 컨테이너에 docker exec 명령어로 접속하여 명령어를 실행할 수도 있지만, 컨테이너 내부에 설치되어 있지 않은 라이브러리를 이용해야 할 수도 있고, 컨테이너로 직접 들어가는 작업이 번거로울 수 있다. 따라서 컨테이너를 띄우는 주체인 워커 노드에서 직접 Docker 컨테이너로 명령을 실행(주입) 시킬 수 있는 방법을 알아보자. 먼저 Docker 컨테이너의 ID가 필요하다. Docker 컨테이너의 ID는 아래와 같이 찾을 수 있다. $ sudo docker ps -a | grep {내가 찾으려는 컨테이너 명} # 예) $ sudo docker ps -a | grep nginx 41e.. Docker Exited된 컨테이너 한번에 삭제하는 명령어 sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm 참고 : https://coderwall.com/p/zguz_w/docker-remove-all-exited-containers Docker: remove all Exited containers (Example) A protip by filosottile about shell and docker. coderwall.com Dockerfile 여러개 두고 골라서 쓰는 방법 여러개의 Dockerfile을 두고 골라서 빌드 가능 예 ) docker build -t api-server:latest . -f dev.Dockerfile docker build -t api-server:latest . -f stg.Dockerfile docker build -t api-server:latest . -f prod.Dockerfile docker build -t : . -f 이전 1 다음