I have a mac and parallels with windows 10. I compiled the webapi template in visual studio 2017 on windows without docker support to a folder on my mac. For some reason, I can't get the docker image to run (hello-world image works fine). Docker is installed on the Mac. Here are my steps:
dotnet restore ./WebApplication1.sln
dotnet publish ./WebApplication1.sln -c Release -o ./obj/Docker/publish
Here is my docker file located in the project directory
FROM microsoft/aspnetcore:latest
ARG source
WORKDIR /app
EXPOSE 5000
COPY ${source:-obj/Docker/publish} /app
ENTRYPOINT ["dotnet", “WebApplication1.dll"]
Calling docker commands from the terminal
docker build WebApplication1 -t WebApplication1
docker run -d -p 5000:5000 WebApplication1
This gives me a container id but it never starts. I hope I am missing something simple. Please advise.
Using docker-compose solved the issue. There could have been some type of syntax error or typo in my previous post. It is worth it to use parallels, visual studio, and a mac. Running docker on anything less than Windows 10 enterprise is not supported with the latest version of docker.
version: '2'
services:
webapplication3:
image: webapplication3
build:
context: ./WebApplication3
dockerfile: Dockerfile
Docker File
FROM microsoft/aspnetcore:latest
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
RUN ls /app
ENTRYPOINT ["dotnet", "WebApplication3.dll"]
Related
while attempting to build an image in Docker/macOS, I get the following error:
failed to compute cache key: failed to create hash for
/app-temp/client/dist: operation not supported
My Dockerfile looks like this:
FROM node:lts-alpine as ui-build
WORKDIR /app-temp
COPY client/ ./client/
RUN cd client && npm install
RUN cd client && npm run build
FROM node:lts-alpine as api-build
WORKDIR /app
COPY --from=ui-build /app-temp/client/dist ./client/dist
COPY server/ ./server/
RUN cd server && npm install
EXPOSE 3000
CMD ["node", "/app/server/src/index.js"]
And the docker command that I am using is:
docker build -t test-image .
Now, note that the image is successfully built in a Linux machine. However, the above-mentioned error persists in a macOS machine.
I am running macOS Big Sur 11.2.1.
Any ideas as to how solve this problem?
Thanks in advance.
just in case someone else finds himself here
Look in your .dockerignore file if dist is in the list
Also, try building with BUILDKIT disabled
DOCKER_BUILDKIT=0 docker build ....
Im gonna throw my solution out there.
Setup: .net 5 web app with docker enabled, contains a dockerfile that was created by visual studio.
There was a step where the docker file was saying to copy my csproj up to the parent folder. I edited the source directory to from parent/myproject.csproj to myproject.csproj then I ran docker build and it worked.
Im assuming that when I run docker build I was down one level in the child folder where the dockerfile lives, and the paths just werent lining up.
I want to run the streamlit through docker. I did not find any official image. Can someone please guide me with the steps required to achieve this or Dockerimage for streamlit?
Here is the details
Operating System: Windows 10 Home
Docker version 19.03.1
Streamlit, version 0.61.0
You can look into this docker hub image.
docker run -it -p 80:80 --entrypoint "streamlit" marcskovmadsen/awesome-streamlit:latest run app.py
Not sure about the streamlit version but you can create one base on this Dockerfile.
Or you can explore streamlit-docker, working for me on my local system.
Quick Setup (own image)
Dockerfile
# Nicked from: https://github.com/markdouthwaite/streamlit-project/blob/master/Dockerfile
FROM python:3.8.4-slim
RUN pip install -U pip
COPY requirements.txt app/requirements.txt
RUN pip install -r app/requirements.txt
# copy into a directory of its own (so it isn't in the toplevel dir)
COPY . /app
WORKDIR /app
CMD ["python", "-m", "streamlit.cli", "run", "main.py", "--server.port=8080"]
EXPOSE 8080
requirements.txt
Then, in the same directory, example contents of the requirements.txt file:
streamlit==0.76.0
pandas==1.2.1
numpy==1.19.5
docker-compose.yml
In a directory above your Dockerfile and source code, you can add:
version: "3.7"
services:
streamlit:
build:
context: streamlit/
volumes:
- ./streamlit:/app
ports:
- 8080:8080
I've got Docker setup on a Raspberry Pi 4 and I want to deploy a ASP.NET Core 3.1 app (The Razor pages movie example app) to my Pi via Docker Hub. When I pull the image from Docker hub and try to run it, I get the error
standard_init_linux.go:211: exec user process caused "exec format error
I've built my Docker image on a Windows 10 x64 PC. When inspecting the Docker image on my Pi, I can see that the architecture is wrong
"Architecture": "amd64",
It should be possible to build a Docker image targeting ARM on a x64 machine since last year, but somehow my image is built targeting x64 instead. I've changed my Dockerfile to target linux-arm
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["RazorMovies/RazorMovies.csproj", "RazorMovies/"]
RUN dotnet restore "RazorMovies/RazorMovies.csproj" -r linux-arm
COPY . .
WORKDIR "/src/RazorMovies"
RUN dotnet build "RazorMovies.csproj" -c Release -o /app/build -r linux-arm
FROM build AS publish
RUN dotnet publish "RazorMovies.csproj" -c Release -o /app/publish -r linux-arm
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RazorMovies.dll"]
and I've changed the target runtime-setting found in Build -> Publish in VS2019 to target linux-arm as well as shown in the image below.
I know that my Pi is capable of running ASP.NET Core apps through Docker, I've run the same app through Docker by using the example found here. That image shows the architecture as arm instead of amd64.
docker run --rm -it -p 8000:80 mcr.microsoft.com/dotnet/core/samples:aspnetapp
What am I missing for my image to be built targeting ARM instead of x64?
Found the solution, I also needed to change the base from
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
to
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim-arm32v7 AS base
I am just getting started with the docker.
I installed the windows version of the docker and followed some basic steps as given in https://hub.docker.com/?overlay=onboarding.
Unable to build the docker file.
I just cloned a git repo from that
by :
git clone https://github.com/docker/doodle.git
then try to build the docker
cd doodle\cheers2019 ;
docker build -t myrepo/cheers2019 .
I am getting the response on the command line:
Sending build context to Docker daemon 13.31kB
Step 1/9 : FROM golang:1.11-alpine AS builder
1.11-alpine: Pulling from library/golang
no matching manifest for windows/amd64 10.0.18362 in the manifest list entries
DokerFile has
FROM golang:1.11-alpine AS builder
RUN apk add --no-cache git
RUN go get github.com/pdevine/go-asciisprite
WORKDIR /project
COPY cheers.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o cheers cheers.go
FROM scratch
COPY --from=builder /project/cheers /cheers
ENTRYPOINT ["/cheers"]
My PC specs:
Windows 10 - AMD Ryzen5 Processor
Is there is an issue with the AMD processor? Please suggest me some way to solve this.
This is followed by docker/doodle issue 9, and it includes a workaround.
But also the simpler advice:
An alternative is to go to Docker Desktop and select Switch to Linux Containers.
The problem is due to the -alpine part of the tag which unfortunately there is no alpine Linux container which will run on Windows.
I have this Golang based Dockerfile:
FROM golang:latest
RUN mkdir -p /app
WORKDIR /app
COPY bin/huru .
CMD ./huru
I checked and the huru binary file is in the working dir. I get this error:
/bin/sh: 1: ./huru: Exec format error
anyone know what that is about? "docker build" succeeds, but "docker run" fails with that error.
The "Exec format error" was simply because I was copying the binary file built on OSX/MacOS into the Docker image and trying to run that binary file in the Linux container. That don't work.
Here is the Dockerfile that worked for me:
FROM golang:latest
RUN mkdir -p /app
WORKDIR /app
COPY . .
ENV GOPATH /app
RUN go install huru
ENTRYPOINT /app/bin/huru
and my project structure like so on my host fs:
$GOPATH/
src/
huru/
.dockerignore
Dockerfile
I run:
docker build -t foo .
docker run foo
my .dockerignore file contains:
.vscode
bin
pkg
If you want to run the docker image on Macos then just specifying the target OS is sufficient:
Assuming there is a src and bin folder, execute in the src folder:
env GOOS=linux go build -o ../bin
(this works with m1, uses the arm64 architecture)
BTW
I would not use latest, I see that there is a docker image based on 1.20 which is not yet officially released at time of writing.
You could build your application (huru) for the target architecture in MacOS and then copy it into the docker image. To build for the target architecture you have to use command in the following format:
env GOOS=linux GOARCH=amd64 go build -o application main.go
This has the added advantage of having a clean dockerfile and smaller image.