μ΄λ² μ€μ΅μμ λ€λ£° λ΄μ©μ ν¬κ² μ€μνμ§λ μμ§λ§ μΈμ κ° νμν μλ μκΈ°λλ¬Έμ λ³λ λ²μΈλ‘ μμ±ν©λλ€ :)
λ컀 νλ‘μΈμ€λ₯Ό μ μνλ νμΌμ μ§μ λ€μ΄κ°μ λ΄μ©μ μμ νλ μ€μ΅μ μ§νν©λλ€.
μ, νλ² ν΄λ΄ μλ€! π
λ컀 컨ν μ΄λλ₯Ό μ€νν©λλ€.
[root@docker /]# docker container run --name nginx -d -p 8080:80 nginx
d66376e534babcd49e947d2766c01dac442a1c0daaa3d3f7643434b05bc210ae
λͺ©λ‘μ νμΈν΄λ΄ μλ€.
root@docker /]# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d66376e534ba nginx "/docker-entrypoint.…" 11 seconds ago Up 11 seconds 0.0.0.0:8080->80/tcp nginx
μ΄μ λ컀 λ°λͺ¬μ μ μ μ€μ§ν©λλ€.
[root@docker /]# systemctl stop docker
/var/lib/docker/container κ²½λ‘μ λ€μ΄κ°λ©΄ μμ£Ό κΈ΄ λ¬Έμκ° μμν
λ°, μ΄ λ¬Έμλ Conteiner IDμ μμͺ½μ΄ μΌμΉν©λλ€ :)
μ¬λ¬κ°μ 컨ν
μ΄λκ° μλ κ²½μ° μ»¨ν
μ΄λ IDλ₯Ό νμΈνμ¬ κ΅¬λΆν μ μμ΅λλ€.
μ΄ κ²½λ‘λ‘ κ°λ©΄ 컨ν
μ΄λ μ€νμ νμν νμΌλ€μ νμΈν μ μμ΅λλ€.
μ΄μ€μμλ hostconfig.json νμΌμ λ³κ²½ν΄λ³΄λλ‘ νκ² μ΅λλ€.
[root@docker /]# cd /var/lib/docker/containers/d66376e534babcd49e947d2766c01dac442a1c0daaa3d3f7643434b05bc210ae/
[root@docker d66376e534babcd49e947d2766c01dac442a1c0daaa3d3f7643434b05bc210ae]# ls -al
ν©κ³ 28
drwx------. 4 root root 237 9μ 28 05:06 .
drwx------. 3 root root 78 9μ 28 05:06 ..
drwx------. 2 root root 6 9μ 28 05:06 checkpoints
-rw-------. 1 root root 2680 9μ 28 05:06 config.v2.json
-rw-r-----. 1 root root 1072 9μ 28 05:06 d66376e534babcd49e947d2766c01dac442a1c0daaa3d3f7643434b05bc210ae-json.log
-rw-r--r--. 1 root root 1512 9μ 28 05:06 hostconfig.json
-rw-r--r--. 1 root root 13 9μ 28 05:06 hostname
-rw-r--r--. 1 root root 174 9μ 28 05:06 hosts
drwx------. 2 root root 6 9μ 28 05:06 mounts
-rw-r--r--. 1 root root 102 9μ 28 05:06 resolv.conf
-rw-r--r--. 1 root root 71 9μ 28 05:06 resolv.conf.hash
hostconfig.json νμΌ λ΄μ©μ μλμ κ°μ΅λλ€ :)
μ λ μ΄ λ΄μ©μ€μ "HostPort":"8080" κ°μ λ³κ²½ν΄μ€κ²μ. (viμλν°λ₯Ό μ¬μ©νμ¬ λ³κ²½ν΄μ£ΌμΈμ)
[root@docker d66376e534babcd49e947d2766c01dac442a1c0daaa3d3f7643434b05bc210ae]# cat hostconfig.json
{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"default","PortBindings":{"80/tcp":[{"HostIp":"","HostPort":"8080"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"CapAdd":null,"CapDrop":null,"Capabilities":null,"Dns":[],"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","ConsoleSize":[0,0],"Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":null,"BlkioDeviceWriteBps":null,"BlkioDeviceReadIOps":null,"BlkioDeviceWriteIOps":null,"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"KernelMemory":0,"KernelMemoryTCP":0,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/asound","/proc/acpi","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/timer_list","/proc/timer_stats","/proc/sched_debug","/proc/scsi","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]}
μ λ³κ²½λ νμ κ°μ μλμ κ°μ΅λλ€. "HostPort":"8090"μΌλ‘ λ³κ²½νμμ΅λλ€.
[root@docker d66376e534babcd49e947d2766c01dac442a1c0daaa3d3f7643434b05bc210ae]# cat hostconfig.json | grep HostPort
{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"default","PortBindings":{"80/tcp":[{"HostIp":"","HostPort":"8090"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"CapAdd":null,"CapDrop":null,"Capabilities":null,"Dns":[],"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","ConsoleSize":[0,0],"Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":null,"BlkioDeviceWriteBps":null,"BlkioDeviceReadIOps":null,"BlkioDeviceWriteIOps":null,"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"KernelMemory":0,"KernelMemoryTCP":0,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/asound","/proc/acpi","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/timer_list","/proc/timer_stats","/proc/sched_debug","/proc/scsi","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]}
μ΄μ Docker λ°λͺ¬μ μ€ννκ³ μ»¨ν
μ΄λ μνλ₯Ό νμΈν©λλ€.
μμλ Stopλ μνμ
λλ€.
[root@docker /]# systemctl start docker
[root@docker /]# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d66376e534ba nginx "/docker-entrypoint.…" 3 minutes ago Exited (0) 2 minutes ago nginx
컨ν
μ΄λλ₯Ό μ€ννκ³ μνλ₯Ό νμΈν©λλ€.
μ΄μ μ μμ μΌλ‘ UPμνκ° λμλ€μ "0.0.0.0:8090->80/tcp"μΌλ‘ λ³κ²½λκ² νμΈμ΄ κ°λ₯ν©λλ€ :)
[root@docker /]# docker start nginx
nginx
[root@docker /]# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d66376e534ba nginx "/docker-entrypoint.…" 3 minutes ago Up 1 second 0.0.0.0:8090->80/tcp nginx