Docker 명령어 모음
type1
type2
명령어
샘플
로그인
login
docker login -u {유저네임} -p {패스워드}
docker login -u AA -p BB
이미지
빌드
docker image build -t {이미지명:태그명} {Dockerfile 경로}
doker image build -t hello-world:latest .
PULL
docker image pull {이미지명:태그명}
docker image pull hello-world:latest
목록 조회
docker image ls
-f 옵션 (도커파일 이름으로 빌드)
docker image build -f {도커파일} -t {이미지명:태그명} {도커파일 경로}
docker image build -f Dockerfile-custom -t hello-world:latest .
검색
docker search [options] {이미지명}
docker search --limit 5 hello-world
태그 붙이기
docker image tag {기존이미지명:태그명} {새이미지명:태그명}
docker image tag hello-world:latest foo-bar:latest
push
docker image push [options] {레파지토리명:태그}
docker image push foo-bar:latest
컨테이너
목록 조회
docker container ls
docker container ls
--filter : 목록 필터링
docker container ls --filter "name:hello-world"
docker container ls --filter "ancestor:hello-world"
-a : 종료 컨터이너 조회
docker container ls -a
생성 및 실행
docker container run [options] {이미지명:태그} {명령} {명령인자}
docker container run -d -p 8080:8080 hello-world:latest
-d 옵션 : 데몬실행
docker container run -d -p 8080:8080 --name foo-bar hello-world:latest
--name : 이름 지정
-v : 볼륨지정
docker container run -v ~/docker-workspace hello-world:latest
-it : 표준 입력 및 연결 유지, 터미널 활성화
정지
docker container stop {컨테이너 ID or 이름}
docker container stop hello-world
재시작
docker container restart {컨테이너 ID or 이름}
docker container restart hello-world
삭제
docker container rm {컨테이너 ID or 이름}
docker container rm hello-world
-f : 실행중인 컨테이너 삭제
docker container rm -f hello-world
로그
docker container logs [options] {컨테이너 ID or 이름}
docker container logs -f hello-world
docker container logs -f $(docker container ls --filter "name=hello-world" -q)
명령 실행하기
docker container exec [options] {컨테이너 ID or 이름} {실행명령어}
docker container exec -it hello-world /bin/bash
복사
docker container cp [options] {컨테이너 ID or 이름:원본파일} {호스트(로컬)파일}
docker container cp hello-world:/tmp/sample.txt .
docker container cp [options] {호스트(로컬)파일} {컨테이너 ID or 이름:파일}
docker container cp sample.txt hello-world:/tmp
사용현황(top)
docker container stats [options] {컨테이너 ID}
docker container stats
이미지, 컨테이너 파기
컨터이너 파기
docker container prune
이미지 파기
docker image prune
컨터이너, 이미지, 볼륨등 파기
docker system prune
Docker-Compose 명령어 모음
type
명렁어
샘플
실행
docker compose up
-d : 데몬 실행
docker compose up -d
--build : 이미지 강제 빌드
docker compose up -d --build
-f : 파일명 지정
docker compose -f docker-compose-custom.yaml up
중지
docker compose down
+
Last updated
Was this helpful?