Следуя этому учебному пособию о том, как упаковать бинарную бинар в докер, при запуске Docker подключение SSH падает. Почему? package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/hello", HelloHandler)
fmt.Printf("Server running (port=8080), route: http://localhost:8080/hello\n")
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal(err)
}
}
func HelloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World!")
}
dockerfile:
# ---- Build stage ----
FROM golang:1.23-alpine AS builder
RUN apk add --no-cache build-base
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o hello_go_http
# ---- Runtime stage ----
FROM alpine:3.20
# Install shell and any useful tools for debugging
RUN apk add --no-cache bash curl
WORKDIR /
# Copy binary from builder
COPY --from=builder /app/hello_go_http .
EXPOSE 8080
ENTRYPOINT ["/hello_go_http"]
< /code>
$ docker build -t hello_go_http .
$ docker run -p 8080:8080 --memory=256m --cpus=1 -t hello_go_http
Server running (port=8080), route: http://localhost:8080/hello
Connection reset by 10.3.1.2 #
(Hang occured after a few seconds. And the HTTP server works well in those few seconds, or after and from local console instead of SSH.)
As expected, the docker stats doesn't show particular RAM consumption:
$ docker stats 06e2
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
06e2f43ecd2b magical_sutherland 0.04% 6.863MiB / 256MiB 2.68% 10.3kB / 790B 4.41MB / 0B 5
Подробнее здесь: https://stackoverflow.com/questions/797 ... connection
Почему этот Tiny Go+Docker Server Crash SSH -соединение? ⇐ Linux
-
Anonymous
1759150287
Anonymous
Следуя этому учебному пособию о том, как упаковать бинарную бинар в докер, при запуске Docker подключение SSH падает. Почему? package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/hello", HelloHandler)
fmt.Printf("Server running (port=8080), route: http://localhost:8080/hello\n")
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal(err)
}
}
func HelloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World!")
}
[b] dockerfile: [/b]
# ---- Build stage ----
FROM golang:1.23-alpine AS builder
RUN apk add --no-cache build-base
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o hello_go_http
# ---- Runtime stage ----
FROM alpine:3.20
# Install shell and any useful tools for debugging
RUN apk add --no-cache bash curl
WORKDIR /
# Copy binary from builder
COPY --from=builder /app/hello_go_http .
EXPOSE 8080
ENTRYPOINT ["/hello_go_http"]
< /code>
$ docker build -t hello_go_http .
$ docker run -p 8080:8080 --memory=256m --cpus=1 -t hello_go_http
Server running (port=8080), route: http://localhost:8080/hello
Connection reset by 10.3.1.2 #
(Hang occured after a few seconds. And the HTTP server works well in those few seconds, or after and from local console instead of SSH.)
As expected, the docker stats doesn't show particular RAM consumption:
$ docker stats 06e2
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
06e2f43ecd2b magical_sutherland 0.04% 6.863MiB / 256MiB 2.68% 10.3kB / 790B 4.41MB / 0B 5
Подробнее здесь: [url]https://stackoverflow.com/questions/79778112/why-does-this-tiny-godocker-server-crash-ssh-connection[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия