我已经尝试了所有方法都没有解决我的热重载问题,容器将正常加载并构建代码,但是修改代码后代码会改变,但空气包不会进行任何重建。

如果编辑某些代码,此状态不会改变。

http://img4.sycdn.imooc.com/634d3c130001dbbd06800418.jpg

如果在本地运行一切正常。 

http://img1.sycdn.imooc.com/634d3c1e0001773b02170058.jpg

Dockerfile:

FROM golang:alpine

ENV GO111MODULE=on


EXPOSE 8080


RUN mkdir /app

WORKDIR /app


COPY go.mod .

COPY go.sum .


RUN go mod download

RUN go get github.com/cosmtrek/air


COPY . .


ENTRYPOINT ["air", "-c", ".air.toml"]

码头工人-compose.yml


   go:

    container_name: go

    build:

      dockerfile: Dockerfile

      context: ./

    volumes:

      - ./:/app

    ports:

      - '8080:8080'

.air.toml


root = "."

testdata_dir = "testdata"

tmp_dir = "tmp"


[build]

  bin = "./tmp/main"

  cmd = "go build -o ./tmp/main ."

  delay = 1000

  exclude_dir = ["assets", "tmp", "vendor", "testdata"]

  exclude_file = []

  exclude_regex = ["_test.go"]

  exclude_unchanged = false

  follow_symlink = false

  full_bin = ""

  include_dir = []

  include_ext = ["go", "tpl", "tmpl", "html"]

  kill_delay = "0s"

  log = "build-errors.log"

  send_interrupt = false

  stop_on_error = true


[color]

  app = ""

  build = "yellow"

  main = "magenta"

  runner = "green"

  watcher = "cyan"


[log]

  time = false


[misc]

  clean_on_exit = false


[screen]

  clear_on_rebuild = false