Operating System Used: Windows 11
Docker:Docker Desktop for Windows
1. Use the following Dockerfile
FROM Golang: 1.18
ENV TZ/usr/share/zoneinfo/Asia/Tokyo
ENV ROOT=/go/src/app
WORKDIR${ROOT}
ENV GO111 MODULE=on
COPY.
EXPOSE 8080
RUN go install github.com/cosmtrek/air@latest
CMD ["air"]
It looks like it's starting up, but if you make changes to the Go file here, it won't hot reload
I would appreciate it if you could tell me how to solve the problem if you know the cause.
windows docker go
"Go's air" is a tool that automatically detects source code changes and restarts applications (here Echo).
GitHub-cosmtrek/air:☁ LLive reload for Goapps
On the other hand, Docker features the ability to build images from source code and boot and run from the same state.
In the Dockerfile listed, copy the current source code to the Docker image at the time of the line COPY.
, and the Docker container is running with this code.
Therefore, when editing the code at hand, the air inside the Docker cannot detect it and does not result in a hot reload.
There are two possible ways to avoid containers or mount development environment directories.
© 2024 OneMinuteCode. All rights reserved.