Launching a Container
Run a container
$ docker run <image>
Shell
볡μ¬
runμ execμ λΉμ·ν μνμ μ€ννμ§λ§ λ€λ₯Έ μ μ 컨ν
μ΄λ μ¬μ€ν μ¬λΆμ
λλ€.
runμ μ€νμμ μλ‘μ΄ μ»¨ν
μ΄λλ₯Ό λμ°λ λ°λ©΄ execλ μ€νλμ΄ μλ 컨ν
μ΄λμ μ μν©λλ€.
execλ νλ‘μΈμ€λ₯Ό μ€νμμΌ λμ λ μ¬μ©λκ³ runμ batch μμ
μ νΉνλμ΄ μμ΅λλ€.
Run container and drop to shell
$ docker run -it <image>
Shell
볡μ¬
-i νμ€ μ
λ ₯(stdin)μ νμ±ννλ©° 컨ν
μ΄λμ μ°κ²°λμ΄ μμ§ μλλΌλ νμ€ μ
λ ₯μ μ μ§ν©λλ€.
-t TTY λͺ¨λλ₯Ό μ¬μ©ν©λλ€. Shellμ μ¬μ©νλ €λ©΄ μ΄ μ΅μ
μ μ¬μ©ν΄μΌ ν©λλ€.
$ docker run --interactive --tty <image>
Shell
볡μ¬
Run container in backgrand
$ docker run -d <image>
Shell
볡μ¬
Container restart settings
$ docker run --restart (always|no|on-failure[:maxretries][unless-stopped) <image>
Shell
볡μ¬
Remove container when exited
$ docker run --rm <image>
Shell
볡μ¬
Provide container nickname
$ docker run --name <name> <image>
Shell
볡μ¬
Accessing the Container
Start a container
$ docker start <container>
Shell
볡μ¬
Run a command against a container
$ docker exec <container> <command>
Shell
볡μ¬
Drop into a shell
$ docker exec -it <container> <shell>
Shell
볡μ¬
Copy file to container / copy container file to localhost
$ docker cp <source> <container>:<destination>
$ docker cp <container>:<source> <destination>
Shell
볡μ¬
Container Management
Stop and restart a container
$ docker stop <container>
$ docker restart <container>
Shell
볡μ¬
Remove a container
$ docker rm <container>
Shell
볡μ¬
Remove all stopped containers
$ docker container prune
Shell
볡μ¬
docker μ€λΈμ νΈ κ°λΉμ§ 컬λ μ
κΈ°λ₯μ΄λΌκ³ μκ°νλ©΄ μ½μ΅λλ€.
μ¬μ©νμ§ μλ container μΌκ΄ μμ ν©λλ€.
Rename a container
$ docker rename <container> <new-name>
Shell
볡μ¬
View container metrics
$ docker stats [<container>]
Shell
볡μ¬
Publishing the Container
View container information
$ docker inspect <container>
Shell
볡μ¬
containerμ λν μΈλΆ μ 보 νμΈμ ν μ μμ΅λλ€.
Create a container image
$ docker commit <container> <name>
Shell
볡μ¬
container μμμ μμ
ν λ΄μ©μ μ΄λ―Έμ§λ‘ commit ν μ μκ³ λμ€μ λ€μ containerλ₯Ό μ±ννλ―λ‘μ¨ μμ
νλ λ΄μ©μ λ€μ μ¬μ©ν μ μμ΅λλ€.