I’m facing an issue, am trying to run my go fiber project inside docker with air
but am getting this error
uni-blog | /bin/sh: 1: /app/tmpmain.exe: not found
am using
Windows 11
Docker desktop
golang latest
air 1.27.10
fiber latest
Here is my docker compose and dockerfile
# docker-compose up -d --build
version: "3.8"
services:
app:
container_name: uni-blog
image: app-dev
build:
context: .
target: development
volumes:
- ./:/app
ports:
- 3000:3000
FROM golang:1.17 as development
RUN apt update && apt upgrade -y &&
apt install -y git
make openssh-client
RUN curl -fLo install.sh https://raw.githubusercontent.com/cosmtrek/air/master/install.sh
&& chmod +x install.sh && sh install.sh && cp ./bin/air /bin/air
RUN air -v
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
EXPOSE 3000
CMD air
I also tried installing air following the readME instructions still it gives me this error
Please help
Thanks in advance
2
Answers
The
volumes:
mount you have replaces the/app
directory in the image with content from the host. If the binary is built in the Dockerfile, thatvolumes:
mount hides it; if you don’t have a matching compatible binary on the host in the same place, you’ll get an error like what you see.I’d remove that
volumes:
block so you’re actually running the binary that’s built into the image. Thedocker-compose.yml
file can be reduced to as little as:If you look the error, you ca notice there is a typo between tmp/main.exe:
This is coming from .air.toml config file:
Create .air.toml file in project root like so: