[Docker] Docker 기초 및 명령어 모음
[TOC]
Docker 기본 명령어
docker –help : docker command에 대한 정보를 제공합니다.
help를 참조하여 다양한 명령을 구성할 수 있습니다.
$ docker --help
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Common Commands:
run Create and run a new container from an image
exec Execute a command in a running container
ps List containers
build Build an image from a Dockerfile
bake Build from a file
pull Download an image from a registry
push Upload an image to a registry
images List images
login Authenticate to a registry
logout Log out from a registry
search Search Docker Hub for images
version Show the Docker version information
info Display system-wide information
Management Commands:
ai* Docker AI Agent - Ask Gordon
builder Manage builds
buildx* Docker Buildx
cloud* Docker Cloud
compose* Docker Compose
container Manage containers
context Manage contexts
debug* Get a shell into any image or container
desktop* Docker Desktop commands
extension* Manages Docker extensions
image Manage images
init* Creates Docker-related starter files for your project
manifest Manage Docker image manifests and manifest lists
mcp* Docker MCP Plugin
model* Docker Model Runner (EXPERIMENTAL)
network Manage networks
plugin Manage plugins
sbom* View the packaged-based Software Bill Of Materials (SBOM) for an image
scout* Docker Scout
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Swarm Commands:
swarm Manage Swarm
Commands:
attach Attach local standard input, output, and error streams to a running container
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
export Export a container's filesystem as a tar archive
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
wait Block until one or more containers stop, then print their exit codes
Global Options:
--config string Location of client config files (default "/home/username/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and
default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket to connect to
-l, --log-level string Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/home/username/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/home/username/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/home/username/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Run 'docker COMMAND --help' for more information on a command.
For more help on how to use Docker, head to https://docs.docker.com/go/guides/
docker 명령어는 docker (Management Command) Command
로 구성되어 있습니다.
docker (Management Command) Command
예를 들어,
docker container run
에서 container
는 Management Commands, run
은 Common command에 해당합니다.
여기서 container
는 생략이 가능합니다.
Management command 는 생략이 가능한 경우가 많으며, --help
를 통해 뒤에 올 명령어들을 확인해볼 수 있습니다.
docker container --help
docker container run --help
docker image --help
로그인
이미지 조회
docker image ls (image name) : 로컬에 저장된 (해당 이름의) 모든 이미지 조회
$ docker image ls nginx
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 3b7732505933 2 days ago 236MB
nginx stable-alpine3.21-perl bf8399910eca 5 months ago 127MB
이미지 파일명
컨테이너 실행 및 확인
docker container 의 생명주기
docker run (OPTION) [image_name]
실행 중인 컨테이너의 ID가 출력됩니다.
실행 중인 컨테이너 목록 확인
docker ps
실행 중인 컨테이너 삭제
docker rm [image]