monitoring esxi using prometheus : getting error undefined: debug.ReadBuildInfo - go

i am trying monitor esxi via prometheus to grafana using https://github.com/devinotelecom/prometheus-vmware-exporter
when i am running
[root#admin01 prometheus-vmware-exporter]# docker build -t prometheus-vmware-exporter .
Sending build context to Docker daemon 157.7kB
Step 1/9 : FROM golang:1.11 as builder
---> 43a154fee764
Step 2/9 : WORKDIR /src/github.com/devinotelecom/prometheus-vmware-exporter
---> Using cache
---> 6b2aad4c7a43
Step 3/9 : COPY ./ /src/github.com/devinotelecom/prometheus-vmware-exporter
---> Using cache
---> 2f5f1b155f7f
Step 4/9 : RUN go get -d -v
---> Using cache
---> a48d35b3d5e2
Step 5/9 : RUN CGO_ENABLED=0 GOOS=linux go build
---> Running in 86199cee4fcb
# github.com/prometheus/client_golang/prometheus
/go/src/github.com/prometheus/client_golang/prometheus/build_info_collector.go:24:15: undefined: debug.ReadBuildInfo
The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux go build' returned a non-zero code: 2
[root#admin01 prometheus-vmware-exporter]#
Thanks for your help in Advanced

The minimal golang version in prometheus is 1.15, but in the Dockerfile it says 1.11
source : https://github.com/prometheus/client_golang/blob/main/go.mod
Try changing golang:1.11 to golang:1.15++ in Dockerfile

Related

The command '/bin/sh -c go build -o image_srv .' returned a non-zero code: 2

I am trying to build a docker file using docker-compose. Part of the build is related to go language. When I build the code I get the following error. What could be the issue? How do I fix this error ? Could you please advise? I am new to go language
---> Running in 68f94f330d0b
Removing intermediate container 68f94f330d0b
---> 7a9ca17f7bd7
Step 15/16 : RUN go build -o image_srv .
---> Running in 38fa96ef75d6
# golang.org/x/sys/unix
/go/src/golang.org/x/sys/unix/syscall.go:83:16: undefined: unsafe.Slice
/go/src/golang.org/x/sys/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
/go/src/golang.org/x/sys/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
The command '/bin/sh -c go build -o image_srv .' returned a non-zero code: 2
You can find appropriate 1.17 tags by going to https://hub.docker.com/_/golang/tags?page=1&name=1.17
Probably golang:1.17.13-alpine will suite your use case
Take note that you may need to delete any existing docker images so that the image can rebuild
# list docker images
$ docker image ls
# delete image foobar
$ docker rmi foobar

go application build with bazel can't link when running inside container

I am trying to containerize my application build, though, when running the build that uses bazel with bazel-gazelle inside a container I will get this error:
$ bazel run --spawn_strategy=local //:gazelle --verbose_failures
INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/workstation/.cache/bazel/_bazel_workstation/fb227af4c7b6aa39cc5b15d7fd9b737a/external/go_sdk/BUILD.bazel:43:15: GoToolchainBinary external/go_sdk/builder [for host] failed: (Exit 1): go failed: error executing command
(cd /home/workstation/.cache/bazel/_bazel_workstation/fb227af4c7b6aa39cc5b15d7fd9b737a/execroot/__main__ && \
exec env - \
GOROOT_FINAL=GOROOT \
external/go_sdk/bin/go tool link -o bazel-out/host/bin/external/go_sdk/builder bazel-out/host/bin/external/go_sdk/builder.a)
# Configuration: e0f1106e28100863b4221c55fca6feb935acec078da5376e291cf644e275dae5
# Execution platform: #local_config_platform//:host
/opt/go/pkg/tool/linux_amd64/link: mapping output file failed: invalid argument
Target //:gazelle failed to build
INFO: Elapsed time: 2.302s, Critical Path: 0.35s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
I tried to run it standalone:
$ /home/workstation/.cache/bazel/_bazel_workstation/fb227af4c7b6aa39cc5b15d7fd9b737a/external/go_sdk/bin/go tool link -o bazel-out/host/bin/external/go_sdk/builder bazel-out/host/bin/external/go_sdk/builder.a
/opt/go/pkg/tool/linux_amd64/link: mapping output file failed: invalid argument
and still got no success.
Never had this kind of link problem and the linker don't provide much more information. Tried to install all packages I could think of and still no luck.
For context:
Running Ubuntu 20.04 LTS
Docker 20.10.9
Bazel 4.2.2
Rules GO v0.31.0
Bazel Gazelle v0.25.0
Also tried to run it with the strace, though I don't think I am skilled enough to find meaningful information from the tool output.
#edit
For more context:
e$ /home/workstation/.cache/bazel/_bazel_workstation/fb227af4c7b6aa39cc5b15d7fd9b737a/external/go_sdk/bin/go tool link -v -o bazel-out/host/bin/external/go_sdk/builder bazel-out/host/bin/external/go_sdk/builder.a
HEADER = -H5 -T0x401000 -R0x1000
searching for runtime.a in /opt/go/pkg/linux_amd64/runtime.a
/opt/go/pkg/tool/linux_amd64/link: mapping output file failed: invalid argument

Build docker image with azure pipelines still 401 (Unauthorized)

I'm trying to build a linux docker image via azure pipelines.
Main problem is with restore from private feed.
I read many article how to do that but still getting same error
"error : Response status code does not indicate success: 401 (Unauthorized)."
So how its looks my files
Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /src
COPY MyAppService/MyAppService.csproj MyAppService/
COPY NuGet.Config .
ARG NUGET_PAT
ARG AZURE_FEED
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"${AZURE_FEED}\", \"username\":\"docker\", \"password\":\"${NUGET_PAT}\"}]}"
RUN wget -O - https://aka.ms/install-artifacts-credprovider.sh
# check env are ok
RUN printenv
RUN dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"
COPY MyAppService/. MyAppService/
RUN dotnet build "MyAppService/MyAppService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyAppService/MyAppService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyAppService.dll"]
NuGet.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="mytestorganization" value="https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json" />
</packageSources>
</configuration>
And log file from azure pipeline when trying build a image:
2021-05-20T11:36:22.7867465Z ##[section]Starting: build
2021-05-20T11:36:22.7875209Z ==============================================================================
2021-05-20T11:36:22.7875497Z Task : Docker
2021-05-20T11:36:22.7875990Z Description : Build or push Docker images, login or logout, start or stop containers, or run a Docker command
2021-05-20T11:36:22.7876270Z Version : 2.185.0
2021-05-20T11:36:22.7876466Z Author : Microsoft Corporation
2021-05-20T11:36:22.7876713Z Help : https://aka.ms/azpipes-docker-tsg
2021-05-20T11:36:22.7876983Z ==============================================================================
2021-05-20T11:36:27.0474614Z [command]/usr/bin/docker build -f /home/vsts/work/1/s/Dockerfile --label com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/mytestorganization/ --label com.azure.dev.image.system.teamproject=TestProject --label com.azure.dev.image.build.repository.name=MyAppService --label com.azure.dev.image.build.sourceversion=63bc9999e1005c9aec016231dcc0f15cf9ec83da --label com.azure.dev.image.build.repository.uri=https://mytestorganization#dev.azure.com/mytestorganization/TestProject/_git/MyAppService --label com.azure.dev.image.build.sourcebranchname=testbranch --label com.azure.dev.image.build.definitionname=TestProject-CI --label com.azure.dev.image.build.buildnumber=144 --label com.azure.dev.image.build.builduri=vstfs:///Build/Build/144 --build-arg AZURE_FEED=http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json --build-arg NUGET_PAT=wz2ilhvt2urpzqlqlldd2f2hl6do77jkmreydrpmskwco3fc7sva /home/vsts/work/1/s
2021-05-20T11:36:30.9509673Z Sending build context to Docker daemon 203.3kB
2021-05-20T11:36:30.9510485Z
2021-05-20T11:36:31.0442686Z Step 1/32 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS base
2021-05-20T11:36:31.2889870Z 3.1-alpine: Pulling from dotnet/core/aspnet
2021-05-20T11:36:31.2907305Z 540db60ca938: Already exists
2021-05-20T11:36:31.3239989Z 9c2872b91813: Pulling fs layer
2021-05-20T11:36:31.3240441Z 8628df474c5d: Pulling fs layer
2021-05-20T11:36:31.3240760Z b54f4c6d2c91: Pulling fs layer
2021-05-20T11:36:31.3981063Z 9c2872b91813: Verifying Checksum
2021-05-20T11:36:31.3981449Z 9c2872b91813: Download complete
2021-05-20T11:36:31.4335354Z b54f4c6d2c91: Verifying Checksum
2021-05-20T11:36:31.4339309Z b54f4c6d2c91: Download complete
2021-05-20T11:36:31.6869948Z 8628df474c5d: Verifying Checksum
2021-05-20T11:36:31.6870377Z 8628df474c5d: Download complete
2021-05-20T11:36:32.0023325Z 9c2872b91813: Pull complete
2021-05-20T11:36:33.1851800Z 8628df474c5d: Pull complete
2021-05-20T11:36:33.5201247Z b54f4c6d2c91: Pull complete
2021-05-20T11:36:33.5262719Z Digest: sha256:97c4986a2f9c8d2bc40443eb0baac59f35c43c267fc59ecc626b449701152df9
2021-05-20T11:36:33.5294596Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
2021-05-20T11:36:33.5314476Z ---> f039e2539446
2021-05-20T11:36:33.5314887Z Step 2/32 : WORKDIR /app
2021-05-20T11:36:33.5511196Z ---> Running in 935279916ded
2021-05-20T11:36:34.0084321Z Removing intermediate container 935279916ded
2021-05-20T11:36:34.0085263Z ---> acbf5abca7a7
2021-05-20T11:36:34.0085629Z Step 3/32 : EXPOSE 80
2021-05-20T11:36:34.0265101Z ---> Running in f7fa1a4dd856
2021-05-20T11:36:35.0147354Z Removing intermediate container f7fa1a4dd856
2021-05-20T11:36:35.0148907Z ---> ac616daad00f
2021-05-20T11:36:35.0152411Z Step 4/32 : EXPOSE 443
2021-05-20T11:36:35.0322549Z ---> Running in b3850b437c79
2021-05-20T11:36:36.0098236Z Removing intermediate container b3850b437c79
2021-05-20T11:36:36.0099219Z ---> cb4e679d3e31
2021-05-20T11:36:36.0099779Z Step 5/32 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
2021-05-20T11:36:36.5177448Z 3.1-alpine: Pulling from dotnet/core/sdk
2021-05-20T11:36:36.5178298Z 540db60ca938: Already exists
2021-05-20T11:36:36.5178735Z 9c2872b91813: Already exists
2021-05-20T11:36:36.5179120Z 8628df474c5d: Already exists
2021-05-20T11:36:36.5179575Z b54f4c6d2c91: Already exists
2021-05-20T11:36:36.5180041Z c1b534528ba7: Pulling fs layer
2021-05-20T11:36:36.5180819Z db0b8f999807: Pulling fs layer
2021-05-20T11:36:36.5181265Z 668300e8efd0: Pulling fs layer
2021-05-20T11:36:36.5181785Z 668300e8efd0: Verifying Checksum
2021-05-20T11:36:36.5182381Z 668300e8efd0: Download complete
2021-05-20T11:36:36.5182681Z c1b534528ba7: Verifying Checksum
2021-05-20T11:36:36.5182991Z c1b534528ba7: Download complete
2021-05-20T11:36:36.9095207Z db0b8f999807: Verifying Checksum
2021-05-20T11:36:36.9095902Z db0b8f999807: Download complete
2021-05-20T11:36:37.5777094Z c1b534528ba7: Pull complete
2021-05-20T11:36:41.4075714Z db0b8f999807: Pull complete
2021-05-20T11:36:42.0343103Z 668300e8efd0: Pull complete
2021-05-20T11:36:42.0398152Z Digest: sha256:468b7f80a5ddad15081eddf072ea67d2d003e82c7937392bf927692b134633f5
2021-05-20T11:36:42.0430106Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
2021-05-20T11:36:42.0445206Z ---> a08ae6c8a2aa
2021-05-20T11:36:42.0445502Z Step 6/32 : WORKDIR /src
2021-05-20T11:36:42.0748860Z ---> Running in 6dae098fc8ed
2021-05-20T11:36:43.0138598Z Removing intermediate container 6dae098fc8ed
2021-05-20T11:36:43.0139677Z ---> e151bdc4004f
2021-05-20T11:36:43.0140964Z Step 7/32 : COPY MyAppService/MyAppService.csproj MyAppService/
2021-05-20T11:36:44.0159585Z ---> 30c607bb8a6e
2021-05-20T11:36:44.0159936Z Step 8/32 : COPY NuGet.Config .
2021-05-20T11:36:45.0146826Z ---> 21b4b5d1f04c
2021-05-20T11:36:45.0147184Z Step 9/32 : ARG NUGET_PAT
2021-05-20T11:36:45.0460635Z ---> Running in 88d83e60cf3a
2021-05-20T11:36:46.0172444Z Removing intermediate container 88d83e60cf3a
2021-05-20T11:36:46.0173490Z ---> 58d9dde29d1d
2021-05-20T11:36:46.0173821Z Step 10/32 : ARG AZURE_FEED
2021-05-20T11:36:46.0360209Z ---> Running in f10912b5009e
2021-05-20T11:36:47.0134976Z Removing intermediate container f10912b5009e
2021-05-20T11:36:47.0135971Z ---> e792f313ec6c
2021-05-20T11:36:47.0136338Z Step 11/32 : ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
2021-05-20T11:36:47.0340003Z ---> Running in dc9e064c144a
2021-05-20T11:36:48.0165125Z Removing intermediate container dc9e064c144a
2021-05-20T11:36:48.0166236Z ---> 2cb8ce18a003
2021-05-20T11:36:48.0166823Z Step 12/32 : ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"${AZURE_FEED}\", \"username\":\"docker\", \"password\":\"${NUGET_PAT}\"}]}"
2021-05-20T11:36:48.0346391Z ---> Running in 06e748e76592
2021-05-20T11:36:49.0167180Z Removing intermediate container 06e748e76592
2021-05-20T11:36:49.0168216Z ---> 21dff5c2a393
2021-05-20T11:36:49.0168806Z Step 13/32 : RUN wget -O - https://aka.ms/install-artifacts-credprovider.sh
2021-05-20T11:36:49.0331863Z ---> Running in 653d535fd87e
2021-05-20T11:36:50.5360687Z [91mConnecting to aka.ms (104.67.209.176:443)
2021-05-20T11:36:50.9255227Z [0m[91mConnecting to raw.githubusercontent.com (185.199.109.133:443)
2021-05-20T11:36:51.0266615Z [0m[91mwriting to stdout
2021-05-20T11:36:51.0269224Z [0m#!/usr/bin/env bash
2021-05-20T11:36:51.0269620Z # DESCRIPTION: A simple shell script designed to fetch the latest version
2021-05-20T11:36:51.0270020Z # of the artifacts credential provider plugin for dotnet and
2021-05-20T11:36:51.0270333Z # install it into $HOME/.nuget/plugins.
2021-05-20T11:36:51.0270979Z # SEE: https://github.com/Microsoft/artifacts-credprovider/blob/master/README.md
2021-05-20T11:36:51.0271177Z
2021-05-20T11:36:51.0271529Z REPO="Microsoft/artifacts-credprovider"
2021-05-20T11:36:51.0271833Z FILE="Microsoft.NuGet.CredentialProvider.tar.gz"
2021-05-20T11:36:51.0272080Z VERSION="latest"
2021-05-20T11:36:51.0272612Z # URL pattern documented at https://help.github.com/en/articles/linking-to-releases as of 2019-03-29
2021-05-20T11:36:51.0273028Z URI="https://github.com/$REPO/releases/$VERSION/download/$FILE"
2021-05-20T11:36:51.0273327Z NUGET_PLUGIN_DIR="$HOME/.nuget/plugins"
2021-05-20T11:36:51.0273475Z
2021-05-20T11:36:51.0273677Z # Ensure plugin directory exists
2021-05-20T11:36:51.0274069Z if [ ! -d "${NUGET_PLUGIN_DIR}" ]; then
2021-05-20T11:36:51.0274767Z echo "INFO: Creating the nuget plugin directory (i.e. ${NUGET_PLUGIN_DIR}). "
2021-05-20T11:36:51.0275283Z if ! mkdir -p "${NUGET_PLUGIN_DIR}"; then
2021-05-20T11:36:51.0275655Z echo "ERROR: Unable to create nuget plugins directory (i.e. ${NUGET_PLUGIN_DIR})."
2021-05-20T11:36:51.0275955Z exit 1
2021-05-20T11:36:51.0276136Z fi
2021-05-20T11:36:51.0276320Z fi
2021-05-20T11:36:51.0276403Z
2021-05-20T11:36:51.0276599Z echo "Downloading from $URI"
2021-05-20T11:36:51.0276893Z # Extract netcore from the .tar.gz into the plugin directory
2021-05-20T11:36:51.0277180Z
2021-05-20T11:36:51.0277502Z #Fetch the file
2021-05-20T11:36:51.0278259Z curl -H "Accept: application/octet-stream" \
2021-05-20T11:36:51.0278673Z -s \
2021-05-20T11:36:51.0279032Z -S \
2021-05-20T11:36:51.0279377Z -L \
2021-05-20T11:36:51.0279833Z "$URI" | tar xz -C "$HOME/.nuget/" "plugins/netcore"
2021-05-20T11:36:51.0280016Z
2021-05-20T11:36:51.0280338Z echo "INFO: credential provider netcore plugin extracted to $HOME/.nuget/"
2021-05-20T11:36:51.0291723Z [91m- 100% |********************************| 1213[0m[91m 0:00:00 ETA
2021-05-20T11:36:51.0292150Z written to stdout
2021-05-20T11:36:52.0145556Z [0mRemoving intermediate container 653d535fd87e
2021-05-20T11:36:52.0146179Z ---> 90962e0fe2f3
2021-05-20T11:36:52.0146481Z Step 14/32 : RUN printenv
2021-05-20T11:36:52.0341626Z ---> Running in de688137dee7
2021-05-20T11:36:52.3685737Z DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
2021-05-20T11:36:52.3686185Z NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED=true
2021-05-20T11:36:52.3686469Z HOSTNAME=de688137dee7
2021-05-20T11:36:52.3686745Z DOTNET_USE_POLLING_FILE_WATCHER=true
2021-05-20T11:36:52.3686993Z SHLVL=1
2021-05-20T11:36:52.3687187Z HOME=/root
2021-05-20T11:36:52.3687432Z DOTNET_RUNNING_IN_CONTAINER=true
2021-05-20T11:36:52.3687794Z AZURE_FEED=http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json
2021-05-20T11:36:52.3688201Z NUGET_PAT=wz2ilhvt2urpzqlqlldd2f2hl6do77jkmreydrpmskwco3fc7sva
2021-05-20T11:36:52.3689296Z POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetCoreSDK-Alpine-3.13
2021-05-20T11:36:52.3689701Z PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2021-05-20T11:36:52.3690173Z LANG=en_US.UTF-8
2021-05-20T11:36:52.3690539Z LC_ALL=en_US.UTF-8
2021-05-20T11:36:52.3690774Z ASPNETCORE_URLS=
2021-05-20T11:36:52.3691003Z PWD=/src
2021-05-20T11:36:52.3691618Z VSS_NUGET_EXTERNAL_FEED_ENDPOINTS={"endpointCredentials": [{"endpoint":"http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json", "username":"docker", "password":"wz2ilhvt4ghjrpzqlqllxsda2hl6do77jkmreyvotsaskwco3fc7sva"}]}
2021-05-20T11:36:52.3692283Z NUGET_XMLDOC_MODE=skip
2021-05-20T11:36:53.0269908Z Removing intermediate container de688137dee7
2021-05-20T11:36:53.0277361Z ---> 47c3745c86a9
2021-05-20T11:36:53.0278468Z Step 15/32 : RUN dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"
2021-05-20T11:36:53.0300480Z ---> Running in 7cb2aad61823
2021-05-20T11:36:54.4782539Z Determining projects to restore...
2021-05-20T11:36:55.5458935Z /usr/share/dotnet/sdk/3.1.409/NuGet.targets(128,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json. [/src/MyAppService/MyAppService.csproj]
2021-05-20T11:36:55.5459838Z /usr/share/dotnet/sdk/3.1.409/NuGet.targets(128,5): error : Response status code does not indicate success: 401 (Unauthorized). [/src/MyAppService/MyAppService.csproj]
2021-05-20T11:36:55.7208436Z The command '/bin/sh -c dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"' returned a non-zero code: 1
2021-05-20T11:36:55.7348351Z ##[error]The command '/bin/sh -c dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"' returned a non-zero code: 1
2021-05-20T11:36:55.7359274Z ##[error]The process '/usr/bin/docker' failed with exit code 1
2021-05-20T11:36:55.7376406Z ##[section]Finishing: build
I tried many thinks like give full acces token. So what im doing wrong?
Try to add verification information to your package source. Use packageSourceCredentials under custom nuget.config file:
Modify your nuget.config as:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="mytestorganization" value="https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<mytestorganization>
<add key="Username" value="xxxx" />
<add key="Password" value="xxxx" />
</mytestorganization>
</packageSourceCredentials>
</configuration>

how to enlarge docker container size?

I need to create a big docker image with the following steps:
Create Dockerfile with the following info:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-bionic as build
ARG BUILDCONFIG=RELEASE
ARG VERSION=1.0.0
WORKDIR .
COPY . /build/
COPY Model/Model.sln /build/Model/
RUN dotnet build ./build/Model/Model.sln
RUN dotnet restore ./build/Model/Model.sln
WORKDIR /build/Model
RUN dotnet publish Model.sln -c $BUILDCONFIG -o out /p:Version=$VERSION
Build docker image with following command
$ docker build -t modelwithpr .
Sending build context to Docker daemon 27.39GB
Step 1/10 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-bionic as build
3.1.202-bionic: Pulling from dotnet/core/sdk
23884877105a: Pull complete
bc38caa0f5b9: Pull complete
2910811b6c42: Pull complete
36505266dcc6: Pull complete
21e3523d71cd: Pull complete
3c423fdfc300: Pull complete
3c953506ccad: Pull complete
3b8b572de54f: Pull complete
8f2eb870f86d: Pull complete
e52b20b76b9c: Pull complete
Digest: sha256:9ee35c3d8395a15b21cc2eca5d66c8e7df62254c12ddb1249731c568458de124
Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1.202-bionic
---> 82688290b31f
Step 2/10 : ARG BUILDCONFIG=RELEASE
---> Running in 74f348453403
Removing intermediate container 74f348453403
---> f07df710b48e
Step 3/10 : ARG VERSION=1.0.0
---> Running in d1556dc14108
Removing intermediate container d1556dc14108
---> 63b311ef2174
Step 4/10 : WORKDIR .
---> Running in acd6a2b9f467
Removing intermediate container acd6a2b9f467
---> cecc23485351
Step 5/10 : COPY . /build/
Error processing tar file(exit status 1): write /build/Model/bin/Debug/netcoreapp3.1/Microsoft.Data.SqlClient.dll: no space left on device
I check the path Library/Containers/com.docker.docker/Data/vms/0/data and find the Docker.raw file is 59GB(don't know why it's so big).
Is there a way to enlarge the container size?

Static Go Binaries w/ Docker - Entrypoint Not Found

I used Static Go Binaries with Docker on OSX by Nicola Paolucci to try to use static Go binary w/ Docker. I believe I followed every step correctly, but when I run the final image, I get the following error response from Docker.
NOTE The name of my service and executable are netverify
docker: Error response from daemon: Container command '/netverify' not found or does not exist..
My Dockerfile.static looks like the following...
#Create a minimal container to run a Golang static binary
FROM tianon/true
ADD netverify /
EXPOSE 8282
CMD ["/netverify"]
My Dockerfile.build looks like the following...
FROM golang
ADD Makefile /
WORKDIR /
RUN make setup
ADD . /go/src/github.com/eirwin/netverify
RUN make buildgo
CMD ["/bin/bash"]
My Makefile is the following...
GOCMD = go
GOBUILD = $(GOCMD) build
GOGET = $(GOCMD) get -v
GOCLEAN = $(GOCMD) clean
GOINSTALL = $(GOCMD) install
GOTEST = $(GOCMD) test
.PHONY: all
all: build
setup:
$(GOGET) github.com/gorilla/mux
buildgo:
GOOS=linux $(GOBUILD) -o netverify ./go/src/github.com/eirwin/netverify
builddocker:
docker build -t eirwin/netverify -f ./Dockerfile.build .
docker run -t eirwin/netverify /bin/true
docker cp `docker ps -q -n=1`:/netverify .
chmod 755 ./netverify
docker build --rm=true --tag=eirwin/netverify -f Dockerfile.static .
run: builddocker
docker run -p 8282:8282 eirwin/netverify
For the purpose of this post, lets assume I have the following as my golang application.
func main() {
router := mux.NewRouter()
router.HandleFunc("/ping", api.PingHandler).Methods("GET")
http.ListenAndServe(":8282", router)
}
When I run Make run everything seems to work except for when the image is ran.
I can see that the image builds correctly at ~8.5MB
eirwin/netverify latest eae16e146b91 3 seconds ago 8.63 MB
But when If docker run -p 8282:8282 eirwin/netverify is ran I get the following error...
docker: Error response from daemon: Container command '/netverify' not found or does not exist..
The go static build in your makefile is missing some options.
buildgo:
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo -o netverify ./go/src/github.com/eirwin/netverify
The build process can capture the container ID to avoid timing issues.
Separate the tags for build and binary images.
builddocker:
docker build -t eirwin/netverify-build -f ./Dockerfile.build .
CID=$$(docker create eirwin/netverify-build); \
docker cp $$CID:/netverify .; \
docker rm $$CID
chmod 755 ./netverify
docker build --rm=true --tag=eirwin/netverify -f Dockerfile.static .
Your binary Dockerfile.static can start with the scratch blank image.
FROM scratch

Resources