ERROR FROM docker.io/library/build:latest containerizing svelte - docker

I am getting the follow issue, that I can't seem to google correctly. I am trying to build sveltekit inside a container to run on my linux server. I tried several different distros of alpine get the same issue. I get 200 when I try to curl https://docker.io/library/build:latest
=> ERROR FROM docker.io/library/build:latest 1.3s
=> => resolve docker.io/library/build:latest 1.3s
=> CANCELED [deploy-node 1/6] FROM docker.io/library/node:18-alpine3.15#sha256:bc11ceb232df9f6758dd2a05aeb65e103f8e8f9
------
> FROM docker.io/library/build:latest:
------
failed to solve: failed to load cache key: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
version: "3.7"
services:
app-node:
image: svelte-docker-node
build:
context: .
dockerfile: Dockerfile
target: deploy-node
ports:
- 3000:3000
dockerfile
FROM node:18-alpine3.15 AS deploy-node
WORKDIR /app
RUN rm -rf ./*
COPY --from=build /app/package.json .
COPY --from=build /app/build .
RUN yarn --Prod
CMD ["node", "index.js"]

This looks like it's been copied from a multi-stage build, and is missing the other stages.
COPY --from=build /app/package.json .
COPY --from=build /app/build .
The --from option looks for another stage with that name, e.g. you've defined a deploy-node stage:
FROM node:18-alpine3.15 AS deploy-node
When it can't find the stage, it falls back to copying from an image with that name, and there's no build:latest image on Docker Hub, so the copy fails.

Related

ERROR [5/5] COPY ./frontend && ./images ./a. > [5/5] COPY ./frontend && ./images ./app/: failed to compute cache key: "/&&" not found: not found

I am trying to build docker images for my React add and I am in a case that I need to copy the image folder which is located outside my react app( frontend) I have specified in my dockerfile to copy two folders from the destination to the source, but I am getting this error saying that && is not found
NOTE: I can't ignore folder/files inside .dockerignore as I need to build the backend folder in the docker image as well? and also I don't want to have another COPY step like
COPY ./frontend . COPY ./images .
my docker file
FROM node:18-alpine
EXPOSE 3000
WORKDIR /app
COPY ./frontend/package.json .
RUN npm install
COPY ./frontend && ./images .
CMD ["npm", "start"]

Docker Service failed to build: pull access denied, repository does not exist or may require 'docker login'

I have a project that contains a Dockerfile and a docker-compose.yml.
Dockerfile:
FROM mhart/alpine-node:11 AS builder
WORKDIR /app
COPY . .
RUN yarn install
RUN yarn build
WORKDIR /app
COPY --from=builder /app/build .
CMD ["serve", "-p", "80", "-s", "."]
docker-compose.yml:
version: "3"
services:
front:
build: .
ports:
- 8080:80
restart: always
When I try to run it like below.
docker-compose up -d
I get the following message:
Building front
Step 1/8 : FROM mhart/alpine-node:11 AS builder
---> 5ff13b69f215
Step 2/8 : WORKDIR /app
---> Using cache
---> 1da7c0d4dfac
Step 3/8 : COPY . .
---> Using cache
---> 8d82bb9c0ecf
Step 4/8 : RUN yarn install
---> Using cache
---> 1e557a2dbe03
Step 5/8 : RUN yarn build
---> Using cache
---> ea2d3f56ff39
Step 6/8 : WORKDIR /app
---> Using cache
---> 1edb82c45c49
Step 7/8 : COPY --from=builder /app/build .
ERROR: Service 'front' failed to build: invalid from flag value builder: pull access denied for builder, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
I saw another question on Stackoverflow, I think it may be close to my problem.
invalid from flag value build: pull access denied for build, repository does not exist or may require 'docker login'
But I only have a build stage, not two stage like in the question from the link.
Your docker build is failing because you are missing a FROM command for your runtime environment. This appears to be a multi-stage docker build, and you are attempting to copy files from a previous build stage named builder but you are still in the first (and only) stage of your build (which is called builder).
You have two options. Either one should work.
Introduce a second runtime stage to your build:
Add another FROM command with the image that you want as your runtime. I just used mhart/alpine-node:11 again here but you may want a different runtime environment.
FROM mhart/alpine-node:11 AS builder
WORKDIR /app
COPY . .
RUN yarn install
RUN yarn build
FROM mhart/alpine-node:11 AS runtime
RUN yarn global add serve
WORKDIR /app
COPY --from=builder /app/build .
CMD ["serve", "-p", "80", "-s", "."]
Make it a non multi-stage build:
Just remove the COPY command and change your workdir to the build directory:
FROM mhart/alpine-node:11 AS builder
RUN yarn global add serve
WORKDIR /app
COPY . .
RUN yarn install
RUN yarn build
WORKDIR /app/build
CMD ["serve", "-p", "80", "-s", "."]

Running .Net Core Application with docker container but i have an issue like this `0.0.0.0:7001->7001/tcp`

I try to containerize my .net core application but i have an issue on app container ports. It seems as 0.0.0.0:7001->7001/tcp. I think problem exists because of this. Is there any other problems on there?
My dockerfile and docker-compose file like below
Dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-nanoserver-1903 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-nanoserver-1903 AS build
WORKDIR /src
COPY ["Blog.Web/Blog.Web.csproj", "Blog.Web/"]
COPY ["Blog.BLL/Blog.BLL.csproj", "Blog.BLL/"]
COPY ["Blog.DAL/Blog.DAL.csproj", "Blog.DAL/"]
COPY ["Blog.Models/Blog.Models.csproj", "Blog.Models/"]
RUN dotnet restore "Blog.Web/Blog.Web.csproj"
COPY . .
WORKDIR "/src/Blog.Web"
RUN dotnet build "Blog.Web.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "Blog.Web.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Blog.Web.dll"]
Docker-compose.yaml
version: '3.4'
services:
client:
build:
dockerfile: Blog.Web\Dockerfile
context: .
ports:
- "7001:7001"
Bash Display
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b5e3edcbc969 blogwebapplication_client "dotnet Blog.Web.dll" About a minute ago Up About a minute 0.0.0.0:7001->7001/tcp blogwebapplication_client_1
When I try to access my app on localhost:7001 I get an error:
"This site cant be reach".

docker-compose works but heroku.yml fails?

I have a docker-compose file that works just fine, and a test-containers.ps1 script that run docker-compose. Everything works great locally.
version: '3.4'
services:
horizon.api.v1:
image: ${DOCKER_REGISTRY-}horizonapiv1
environment:
ASPNETCORE_ENVIRONMENT: Development
build:
context: .
dockerfile: api/horizon.api.v1/Dockerfile
Here's the dockerfile to which the docker-compose and heroku.yml files refer:
# horizon.api
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY api/horizon.api.v1/horizon.api.v1.csproj api/horizon.api.v1/
RUN dotnet restore api/horizon.api.v1/horizon.api.v1.csproj
COPY . .
WORKDIR /src/api/horizon.api.v1
RUN dotnet build horizon.api.v1.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish horizon.api.v1.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "horizon.api.v1.dll"]
I wanted to get this up and running in Heroku so my students could see it running, and so students that don't have access to docker could play with the application. I made a heroku.yml file that looks like it should work...but this is the first time I've ever used heroku and it's probable I'm doing something stupid.
build:
config:
ASPNETCORE_ENVIRONMENT: Development
docker:
api: ./api/horizon.api.v1/Dockerfile
When I try to push my repo to heroku I get the following error:
remote: Step 7/17 : COPY ["routing/horizon.routing/horizon.routing.csproj", "routing/horizon.routing/"]
remote: COPY failed: stat /var/lib/docker/tmp/docker-builder722311220/routing/horizon.routing/horizon.routing.csproj: no such file or directory
I've seen a few posts online about a .dockerignore file causing problems, so I renamed my .dockerignore file to take it out of the picture until I figure this out.
The paths should all be correct, why does docker-compose not have any problem finding the necessary paths on my local machine but heroku says they don't exist? What am I doing wrong?
I believe it's probably related to the build context. I'm guessing Heroku doesn't use the context from the root of the project, and uses the directory where the Dockerfile is located.

docker-compose error when running netcore-react app

When I build my app without using docker-compose :
docker build -t aspnetapp .
docker run -d -p 8080:80 --name myapp aspnetapp
the docker container runs just fine. But when I try to run it, using docker-compose up, the image builds successfully but the website gives me errors on loading.
dockerfile:
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "app.dll"]
docker-compose:
version: '3.4'
services:
app:
image: aspnetapp
build: ./app
ports:
- "8080:80"
AggregateException: One or more errors occurred. (One or more errors occurred. (Failed to start 'npm'. To resolve this:.
[1] Ensure that 'npm' is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Make sure the executable is in one of those directories, or update your PATH.
removing
environment: - ASPNETCORE_ENVIRONMENT=Development
from the compose.override file fixed all this. I'm not sure why it's the problem.
Is your Dockerfile in ./ or ./app? If it's in ./ change docker-compose.yml to build: ./
EDIT
I've just realised that you are specifying both image and build in your docker-compose.yml; get rid of the image.

Resources