Lab1
μΈμ
λͺ©ν
Docker Container build, run, debug
Docker Hubλ‘λΆν° Docker images pull νκΈ°
Google Container Registry μ Docker image push νκΈ°
Google Cloud
Cloud Shell μ development tools μ λ‘λλλ κ°μ λ¨Έμ μ΄λ€.

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Auth list νμΈ

λ컀 λ°λͺ¬μ hello-world μ΄λ―Έμ§λ₯Ό λ‘컬μμ μ°Ύμ§ λͺ»νλ©΄ Docker Hubμμ μ΄λ―Έμ§λ₯Ό pullνμ¬ μ»¨ν μ΄λλ₯Ό μμ±νκ³ μ€ννλ€.
μ΄λ―Έμ§λ₯Ό ν ν ν λ€μ ν΄λΉ λͺ λ Ήμ΄λ₯Ό μ€ννλ©΄ μ΄μ docker daemonμ local registryμμ μ΄λ―Έμ§λ₯Ό μ°Ύκ³ , κ·Έ μ΄λ―Έμ§λ‘λΆν° 컨ν μ΄λλ₯Ό μ€ννλ€.
Build
The initial line specifies the base parent image, which in this case is the official Docker image for node version long term support (lts).
In the second, you set the working (current) directory of the container.
In the third, you add the current directory's contents (indicated by the "." ) into the container.
Then expose the container's port so it can accept connections on that port and finally run the node command to start the application.
node application
μ νμΌ μμ± ν imageλ₯Ό buildνλ€.
-t λͺ λ Ήμ΄λ name: tag λ‘ νκ·Έλ₯Ό μ§μ νκΈ° μν λͺ λ Ήμ΄.
λ°λΌμ μ΄λ―Έμ§μ μ΄λ¦μ node-app μ΄κ³ , tagλ 0.1μ΄ λλ€.
νκ·Έλ₯Ό μ§μ νμ§ μμΌλ©΄ latest λ‘ μ μ₯λλ€. μ΄λ κ² λλ©΄ μλ‘μ΄ μ΄λ―Έμ§κ° μκ²Όμ λ ν·κ°λ¦¬κΈ° λλ¬Έμ νκ·Έλ₯Ό λ°λμ μ μ₯νλ κ²μ΄ μ€μνλ€.

μ΄λ―Έμ§ λΉλ ν λ컀 μ΄λ―Έμ§ λͺ©λ‘μ νμΈνλ€.
Run
μμμ λΉλν μ΄λ―Έμ§ κΈ°λ°μ 컨ν μ΄λλ₯Ό μ€ννκΈ° μν΄μλ λ€μ λͺ λ Ήμ΄λ₯Ό μ€ννλ€.
βname μ 컨ν μ΄λ μ΄λ¦μ μ§μ ν μ μλλ‘ νλ λͺ λ Ήμ΄μ΄λ€.
-p λ λμ»€κ° νΈμ€νΈμ ν¬νΈ 4000λ²μ 컨ν μ΄λμ 80λ² ν¬νΈλ‘ λ§€ννλλ‘νλ€.
λ°λΌμ νΈμ€νΈλ http://localhost:4000 μμ μλ²λ₯Ό νμΈν μ μλ€.

λ컀 컨ν μ΄λλ₯Ό λμ΄ ν λ€λ₯Έ ν°λ―Έλμμ μλ λͺ λ Ήμ΄λ₯Ό νμΈν΄λ³Έλ€.

λ€μκ³Ό κ°μ λͺ λ Ήμ΄λ₯Ό νμΈν μ μλ€.
λ§μ½ 컨ν μ΄λκ° λ°±κ·ΈλΌμ΄λμμ λ°λͺ¬μΌλ‘ λμκ°λμ§ νμΈνκΈ° μν΄μλ -d flagλ₯Ό λΆμΈλ€.
λ컀 λ΄λ Έλ€κ° backgroundμμ run νλλ‘ νλ λͺ λ Ήμ΄

컨ν μ΄λ μμ΄λλ₯Ό ν΅ν΄ λ‘κ·Έλ₯Ό νμΈνλ€.
app.js νμΌ λ³κ²½ ν λ€μ μ΄λ―Έμ§λ₯Ό λΉλνκ³ μλ‘μ΄ νκ·Έλ₯Ό λΆμΈλ€.

step2 μμλ μ΄λ―Έ μ‘΄μ¬νλ cache layerλ₯Ό μ¬μ©νλ€.
Step3 λΆν°λ app.jsμμ λ³κ²½μ¬νμ΄ μμκΈ° λλ¬Έμ layerλ€λ μμ λλ€.
μλ‘μ΄ μ΄λ―Έμ§λ₯Ό μ΄μ©ν 컨ν μ΄λλ₯Ό μ€ννλ€.
μ΄λ―Έ νΈμ€νΈμ 4000λ² ν¬νΈλ₯Ό μ¬μ©μ€μ΄κΈ° λλ¬Έμ λ€λ₯Έ ν¬νΈλ²νΈλ₯Ό μ¬μ©νλ€.

Debug
컨ν μ΄λ μμ΄λλ₯Ό ν΅ν΄ λ컀 λ‘κ·Έλ₯Ό νμΈνλ€.
컨ν μ΄λμμμ interactive Bash session μ€ν
-it flagλ pseudo-ttyλ₯Ό ν λΉν¨μΌλ‘μ¨ μ»¨ν μ΄λμ μνΈμμ©ν μ μλλ‘ νλ€.
bashλ WORKDIR μΈ /app μμ μ€νλλ€λ κ²μ κΈ°μ΅νμ. (Dockerfile μμ μμ±ν¨)

Publish
μ΄μ μ΄λ―Έμ§λ₯Ό Google Container Registry (gcr)μ νΈμν΄λ³΄μ!
κ·Έ ν 컨ν μ΄λμ μ΄λ―Έμ§λ€μ μμ ν κ²μ΄κ³ , κ·Έ λ€μ ννκ³ μ»¨ν μ΄λλ₯Ό μ€νν κ²μ΄λ€.
gcrμ μ΄λ―Έμ§λ₯Ό νΈμνκΈ° μν΄μλ μ΄λ―Έμ§ μ΄λ¦μ registry nameμΌλ‘ νκ·Έν΄μΌνλ€.
νμμ [hostname]/[project-id]/[image]:[tag] μ΄λ€.
For gcr:
[hostname]= gcr.io
[project-id]= your project's ID
[image]= your image name
[tag]= any string tag of your choice. If unspecified, it defaults to "latest".
project IDλ μλ λͺ λ Ήμ΄λ₯Ό μ€νν΄ νμΈνλ€.
node-app:0.2 λ₯Ό νκΉ ν΄λ³΄μ.

μ΄μ μ΄ μ΄λ―Έμ§λ₯Ό gcrμ νΈμν΄λ³΄μ.
μ΄μ Google Cloudμμ μ΄λ―Έμ§κ° μ νΈμλμλμ§ νμΈνλ€.

μ΄λ―Έμ§ ν
μ€νΈ
λ€μν λ°©λ²μΌλ‘ μλ ν μ μμ§λ§ κ°λ¨ν μ‘΄μ¬νλ κΈ°μ‘΄μ 컨ν μ΄λλ€μ μμ νλ€.
node imageλ₯Ό μ§μ°κΈ° μ μ node:lts μ child images λ€λ μμ ν΄μΌνλ€.
λ€μ λͺ λ Ήμ΄λ₯Ό μ¬μ©νλ€.
μ΄μ μ΄λ―Έμ§λ₯Ό pull νκ³ μ€νν΄λ³΄μ
Last updated