Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-stage error when referencing earlier stage #233

Closed
frelon opened this issue Jul 12, 2018 · 12 comments · Fixed by #266
Closed

multi-stage error when referencing earlier stage #233

frelon opened this issue Jul 12, 2018 · 12 comments · Fixed by #266
Labels
kind/bug Something isn't working

Comments

@frelon
Copy link
Contributor

frelon commented Jul 12, 2018

Hi!

I get the error message UNAUTHORIZED: "authentication required"

when running kaniko with the following Dockerfile

FROM microsoft/dotnet:2.1-runtime AS base
WORKDIR /app

FROM microsoft/dotnet-samples AS build
# Build etc (empty, but here for repro purposes)..

FROM base AS final
COPY --from=build /app /app
ENTRYPOINT ["dotnet", "dotnetapp.dll"]

And these commands on my local machine:

docker run --rm -it --entrypoint=sh -v ${PWD}:/workspace/ gcr.io/kaniko-project/executor:debug-v0.2.0
cd /workspace && /kaniko/executor --dockerfile=/workspace/Dockerfile --context=/workspace --destination=<registry-url>

But when using docker build and docker push/run it works as expected.

@frelon
Copy link
Contributor Author

frelon commented Jul 12, 2018

Moving it around to not be a multi-stage build works:

FROM microsoft/dotnet-samples
COPY /app /app
ENTRYPOINT ["dotnet", "dotnetapp.dll"]

@priyawadhwa
Copy link
Collaborator

Hi @frelon , I think this is happening because we aren't replacing the base name in the last dockerfile stage (so kaniko will try to pull base which doesn't exist, instead of microsoft/dotnet:2.1-runtime).

I'll open a PR which should hopefully fix this

@frelon
Copy link
Contributor Author

frelon commented Jul 13, 2018

HI @priyawadhwa, great! thanks for the quick response!

@priyawadhwa
Copy link
Collaborator

Hi @frelon, this should be fixed now. Let me know if you run into any more problems.

@priyawadhwa
Copy link
Collaborator

I'll go ahead and close this, please open another issue if you run into anything!

@MnrGreg
Copy link

MnrGreg commented Jul 31, 2018

Hi @priyawadhwa I'm getting the following error with multistage builds:

INFO[0065] Not adding /var/run because it is whitelisted
INFO[0065] Taking snapshot of full filesystem...
INFO[0067] cmd: /bin/sh
INFO[0067] args: [-c adduser --system --no-create-home --disabled-login --disabled-password --uid 10001 appuser]
Adding system user appuser' (UID 10001) ... Adding new user appuser' (UID 10001) with group nogroup' ... Not creating home directory /home/appuser'.
INFO[0067] Taking snapshot of full filesystem...
INFO[0068] Storing source image from stage 0 at path /kaniko/stages/0
INFO[0126] Base image from previous stage 1 found, using saved tar at path /kaniko/stages/1
INFO[0126] saving dependencies []
ERRO[0126] open /kaniko/stages/1: no such file or directory

Seems to have an issue maintaining the stages. Any idea what could be happening or how to troubleshoot?

Dockerfile:

FROM container-registry.XXX/stores/aspnetcore:2.0 AS base
RUN adduser --system --no-create-home --disabled-login --disabled-password --uid 10001 appuser

FROM container-registry.XXX/stores/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY App.API.Core/App.API.Core.csproj App.API.Core/
COPY App.API.Data/App.API.Data.csproj App.API.Data/
RUN dotnet restore App.API.Core/App.API.Core.csproj
COPY . .
WORKDIR /src/App.API.Core
RUN dotnet build App.API.Core.csproj -c Release -o /app

FROM build AS publish
RUN dotnet publish App.API.Core.csproj -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
RUN chown -R appuser /app
ENV ASPNETCORE_URLS="http://*:18080"
USER appuser
ENTRYPOINT ["dotnet", "App.API.Core.dll"]

Been using a fairly recent build:
https://console.cloud.google.com/gcr/images/kaniko-project/GLOBAL/executor@sha256:acc0ea50eee204a990a2d477463a2af40785456d1bf1de6af1b5451a2442db68/details?tab=info

@priyawadhwa priyawadhwa reopened this Aug 1, 2018
@priyawadhwa
Copy link
Collaborator

Hey @MnrGreg , thanks for pointing this out! I think this issue is happening because right now kaniko is trying to get dependencies from a future stage which is also built off of a future stage (so it's breaking because the tarball of the future stage doesn't exist yet).

I'll open a PR to fix this bug

@MnrGreg
Copy link

MnrGreg commented Aug 1, 2018

thanks for the quick turnaround @priyawadhwa. will test once merged.

@priyawadhwa
Copy link
Collaborator

@MnrGreg this should work now, let me know if you still have any issues.

@MnrGreg
Copy link

MnrGreg commented Aug 2, 2018

@priyawadhwa it's working thanks. Going onto the next stage now.

INFO[0019] args: [-c adduser --system --no-create-home --disabled-login --disabled-password --uid 10001 appuser]
Adding system user appuser' (UID 10001) ... Adding new user appuser' (UID 10001) with group nogroup' ... Not creating home directory /home/appuser'.
INFO[0019] Taking snapshot of full filesystem...
INFO[0021] Deleting filesystem...
INFO[0021] Downloading base image container-registry.XXX/stores/aspnetcore-build:2.0
INFO[0022] Mounted directories: [/kaniko /var/run /proc /dev /dev/pts /sys /sys/fs/cgroup /sys/fs/cgroup/cpuset /sys/fs/cgroup/cpu /sys/fs/cgroup/cpuacct /sys/fs/cgroup/blkio /sys/fs/cgroup/memory /sys/fs/cgroup/devices /sys/fs/cgroup/freezer /sys/fs/cgroup/net_cls /sys/fs/cgroup/perf_event /sys/fs/cgroup/net_prio /sys/fs/cgroup/hugetlb /sys/fs/cgroup/pids /sys/fs/cgroup/systemd /dev/mqueue /workspace /etc/resolv.conf /etc/hostname /etc/hosts /dev/shm /root/.docker/config.json /kaniko/ssl/certs/ca-certificates.crt/dev/console /proc/bus /proc/fs /proc/irq /proc/sys /proc/sysrq-trigger /proc/acpi /proc/kcore /proc/keys /proc/timer_list /proc/sched_debug /sys/firmware /proc /dev /dev/pts /sys /sys/fs/cgroup /sys/fs/cgroup/cpuset /sys/fs/cgroup/cpu /sys/fs/cgroup/cpuacct /sys/fs/cgroup/blkio /sys/fs/cgroup/memory /sys/fs/cgroup/devices /sys/fs/cgroup/freezer /sys/fs/cgroup/net_cls /sys/fs/cgroup/perf_event /sys/fs/cgroup/net_prio /sys/fs/cgroup/hugetlb /sys/fs/cgroup/pids /sys/fs/cgroup/systemd /dev/mqueue /workspace /etc/resolv.conf /etc/hostname /etc/hosts /dev/shm /root/.docker/config.json /kaniko/ssl/certs/ca-certificates.crt /dev/console /proc/bus /proc/fs /proc/irq /proc/sys /proc/sysrq-trigger /proc/acpi /proc/kcore /proc/keys /proc/timer_list /proc/sched_debug /sys/firmware]
INFO[0022] Unpacking layer: 9
INFO[0032] Whiting out /tmp/.wh.warmup
INFO[0032] Unpacking layer: 8
INFO[0032] Not adding /tmp because it was added by a prior layer

@MnrGreg
Copy link

MnrGreg commented Aug 2, 2018

@priyawadhwa I'm now getting a different error on the next stage (FROM build AS publish):

INFO[0129] args: [-c dotnet build XXXXX.API.Core.csproj -c Release -o /app]
Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages
[redacted]
Time Elapsed 00:00:06.90
INFO[0136] Taking snapshot of full filesystem...
ERRO[0152] archive/tar: sockets not supported

Should I log this under a new issue?

@priyawadhwa
Copy link
Collaborator

@MnrGreg sure, if you could open up a new issue that would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants