15:03 임시

This commit is contained in:
2026-04-08 15:03:55 +09:00
parent 1c346e2014
commit 583b0b58d1
3 changed files with 44 additions and 2 deletions
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
# 베이스 이미지를 지정 (저장소 이름이 없으므로 도커 허브 공식 이미지)
# https://docs.docker.com/engine/reference/builder/#from
# https://hub.docker.com/_/golang
FROM golang:1.23.1
# 컨테이너 내부에 /echo 디렉터리를 생성
# https://docs.docker.com/engine/reference/builder/#run
RUN mkdir /echo
# 호스트의 main.go 파일을 컨테이너의 /echo/main.go로 복사
# https://docs.docker.com/engine/reference/builder/#copy
COPY main.go /echo
# 컨테이너 실행 시 go run /echo/main.go 명령어를 실행
# https://docs.docker.com/engine/reference/builder/#cmd
CMD ["go", "run", "/echo/main.go"]
+26
View File
@@ -0,0 +1,26 @@
/* 8080 포트로 HTTP 요청을 대기하다가, /로 요청이 들어오면 Hello Docker!!!를 응답 */
/* 프로그램의 진입점인 main 패키지를 지정 */
package main
/* 표준 입출력과 문자열 형식을 처리하는 Go 패키지,
로그를 출력하기 위한 패키지,
HTTP 서버와 클라이언트 관련 기능을 제공하는 패키지를 임포트 */
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Println("received request")
fmt.Fprintf(w, "Hello Docker!!")
})
log.Println("start server")
server := &http.Server{Addr: ":8080"}
if err := server.ListenAndServe(); err != nil {
log.Println(err)
}
}