Docker 명령어
author: Dev.ian
createdAt: 2024-08-18
updatedAt: 2024-08-20
Docker Commands
- include Podman commands
Build
-
Docker
$ docker build -f Dockerfile -t devian/spring-boot-docker-test:0.0.1 .
-
Podman
$ podman build -f Dockerfile -t devian/spring-boot-docker-test:0.0.1 .
Run
-
Docker
port
: 8080:80 은 로컬PC의 포트번호(8080):컨테이너의 포트번호(80) 를 의미
$ docker run -p 8080:80 devian/spring-boot-docker-test:0.0.1
Stop
-
Docker
$ docker stop $(docker ps -q)
Access Container
-
Check docker container id
$ docker ps
-
Access docker container
- -it:
i
(STDIN 표 준 입력),t
(가상 tty) 을 통한 접속- tty: teletypewriter, 리눅스의 디바이스 드라이브 중 콘솔 or 터미널을 의미 (※ Linux - 콘솔, 터미널, TTY 이해하기)
$ docker exec -it ${CONTAINER_ID} /bin/bash
- -it:
List Container and Image
List Container (Process)
-
Docker
$ docker ps
$ docker ps -a
$ docker container
$ docker container -a -
Podman
$ podman ps
$ podman ps -a
$ podman container
$ podman container -a
List Image
-
Docker
$ docker image ls
$ docker image ls -a
Remove Container and Image
Prune
$ docker system prune -a # Remove all unused images not just dangling ones
$ docker system prune # Remove unused data
$ docker volume prune # Remove unused local volumes
Remove Container (Process)
-
Docker
$ docker rm ${CONTAINER_ID}
$ docker rm $(docker ps -q -a) # remove all container -
Podman
$ podman rm ${CONTAINER_ID}
$ podman rm -f ${CONTAINER_ID} # force option
Remove Image
-
Docker
$ docker rmi ${IMAGE_ID}
$ docker rmi $(docker images -q) # remove all images -
Podman
$ podman rmi ${IMAGE_ID}
$ podman rmi -f ${IMAGE_ID} # force option