snmp_exporter icon indicating copy to clipboard operation
snmp_exporter copied to clipboard

Failed to build docker image.

Open powertoaster opened this issue 4 years ago • 3 comments

What did you do that produced an error?

docker build -t snmp-generator .

What did you expect to see?

Successful build.

What did you see instead?

#5 269.1 /bin/sh: 1: cd: can't cd to /go/src/github.com/prometheus/snmp_exporter/generator
------
executor failed running [/bin/sh -c apt-get update &&     apt-get install -y libsnmp-dev p7zip-full &&     go get github.com/prometheus/snmp_exporter/generator &&     cd /go/src/github.com/prometheus/snmp_exporter/generator &&     go get -v . &&     go install]: exit code: 2

If I do a docker run -it and run the go get command manually I get this:

go get github.com/prometheus/snmp_exporter/generator
go: downloading github.com/prometheus/snmp_exporter v0.20.0
go: downloading github.com/prometheus/common v0.15.0
go: downloading github.com/go-kit/kit v0.10.0
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/gosnmp/gosnmp v1.29.0
go: downloading github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
go: downloading github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
go: downloading github.com/go-logfmt/logfmt v0.5.0
# github.com/prometheus/snmp_exporter/generator
pkg/mod/github.com/prometheus/[email protected]/generator/net_snmp.go:19:10: fatal error: net-snmp/net-snmp-config.h: No such file or directory
 #include <net-snmp/net-snmp-config.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

powertoaster avatar Apr 29 '21 19:04 powertoaster

I get the same error message: /bin/sh: 1: cd: can't cd to /go/src/github.com/prometheus/snmp_exporter/generator The command '/bin/sh -c apt-get update && apt-get install -y libsnmp-dev p7zip-full && go get github.com/prometheus/snmp_exporter/generator && cd /go/src/github.com/prometheus/snmp_exporter/generator && go get -v . && go install' returned a non-zero code: 2

was following this guide when i ran into the error and i tried running the same commands in the generator section:

https://brendonmatheson.com/2021/02/07/step-by-step-guide-to-connecting-prometheus-to-pfsense-via-snmp.html

mpuleikis1 avatar Aug 03 '21 04:08 mpuleikis1

Still an issue, over an year later.

During the build, I get this error:

debconf: delaying package configuration, since apt-utils is not installed

and at the end:

go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
The command '/bin/sh -c apt-get update &&     apt-get install -y libsnmp-dev p7zip-full unzip &&     go get github.com/prometheus/snmp_exporter/generator &&     cd /go/src/github.com/prometheus/snmp_exporter/generator &&     go get -v . &&     go install' returned a non-zero code: 1

wbarnard81 avatar Aug 04 '22 12:08 wbarnard81

Changed my Dockerfile to this and think that part is at least sorted:

FROM golang:latest

RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y libsnmp-dev p7zip-full unzip apt-utils
#RUN go get github.com/prometheus/snmp_exporter/generator && \
#    cd /go/src/github.com/prometheus/snmp_exporter/generator && \
#    go get -v . && \
RUN go install github.com/prometheus/snmp_exporter/generator@latest

WORKDIR "/opt"

ENTRYPOINT ["/go/bin/generator"]

ENV MIBDIRS mibs

CMD ["generate"]

wbarnard81 avatar Aug 04 '22 12:08 wbarnard81