I am trying to install tesseract-ocr to use within a docker container, but when I feed a request to my api, I still get an error saying "FileNotFoundError: [Errno 2] No such file or directory: 'tesseract': 'tesseract'"
I'm trying to maybe add tesseract to my ENV $Path variable in the Dockerfile, but I'm unable to locate where this tesseract package is even installed. Below I've added my Dockerfile, any help would be appreciated. Thanks!
FROM python:3.6-alpine
RUN apk add --update --no-cache tesseract-ocr
FROM pytorch/pytorch:1.4-cuda10.1-cudnn7-devel
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN pip install .
EXPOSE 5000
WORKDIR /usr/src/app/examples/classification
CMD ["flask", "run", "--host", "0.0.0.0"]
Related
I have the following Dockerfile:
# pull official base image
FROM python:3.9.7-alpine
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install psycopg2 dependencies
RUN apk update \
&& apk add postgresql-dev gcc python3-dev musl-dev binutils \
&& apk add --no-cache proj-dev geos gdal
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# copy entrypoint.sh
COPY ./entrypoint.sh .
RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh
# copy project
COPY . .
# run entrypoint.sh
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
Building the image works fine, but when I try a docker run after building the image I get the following error:
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/src/app/entrypoint.sh": permission denied: unknown.
ERRO[0000] error waiting for container: context canceled
The line RUN chmod +x /usr/src/app/entrypoint.sh doesn't seem to work because when I comment the ENTRYPOINT statement, build the image then start a containerI can see that the execution right isn't added for that file.
Docker version is:
Docker version 20.10.23, build 7155243
I tried replacing the RUN chmod line with a --chmod=777 option to the COPY of the entrypoint and it didn't change anything.
Any idea why a chmod +x would fail in docker ?
I found a workaround by removing the chmod line and replacing the entrypoint line with the following:
ENTRYPOINT ["/bin/sh", "/usr/src/app/entrypoint.sh"]
This way there is no need for a execution right on the entrypoint script.
But I still don't know why the chmod doesn't work.
I have an API written in Flask that's running in 127.0.0.1:3001.
I have it running inside a docker container, and I'd like to know how I can request this API.
Below is my Dockerfile
FROM python:3
WORKDIR /app
ADD requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
ADD . /app
EXPOSE 3001
CMD ["python", "wsgi.py"]
Thanks in advance.
I am trying to create a docker or docker-compose file for a react project that has node-sass.
I have tried this and almost all solution on here but none of them is working.
FROM node:10.17.0-alpine
RUN apk add --no-cache build-base g++ make python
WORKDIR /app
COPY ./ ./
RUN npm install
// This is where node-sass is failing
CMD ["sh"]
The issue is that you are using the alpine version which does not come with node-sass. Use the full node image.
I'm trying to copy my binary file to the container and then execute it on container.
I have the swarm.exe in the same directory as Dockerfile. But I always get the same error: "./swarm: no such file or directory".
My dockerfile:
FROM golang:1.7-alpine
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories
RUN apk update && apk add --update openssl && apk add glide git
RUN mkdir /tools
WORKDIR /tools
RUN wget https://github.com/Masterminds/glide/releases/download/0.10.2/glide-0.10.2-linux-386.tar.gz
RUN tar -zxvf glide-0.10.2-linux-386.tar.gz
RUN mv linux-386/ glide/
ENV PATH /tools/glide:$PATH
WORKDIR /usr/src/app
COPY swarm.exe .
CMD ["./swarm"]
Basically, I'm trying to copy swarm.exe to /usr/src/app (where I am now) and then execute ./swarm
Any ideas?
Thanks
Alpine images are linux based, they do not recognize .exe files like windows. Either do a CMD ["./swarm.exe"] or use a different image.
FROM golang:1.8
RUN apt-get -y update && apt-get install -y curl
RUN go get -u github.com/gorilla/mux
RUN go get github.com/mattn/go-sqlite3
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
apt-get install -y nodejs
COPY . /go/src/beginnerapp
WORKDIR ./src/beginnerapp/beginner-app-react
RUN npm run build
RUN go install beginnerapp/
WORKDIR /go/src/beginnerapp/beginner-app-react
VOLUME /go/src/beginnerapp/local-db
WORKDIR /go/src/beginnerapp
ENTRYPOINT /go/bin/beginnerapp
EXPOSE 8080
At the start, the golang project as well as the reactjs code don't exist on the image and need to be copied over before being able to build (js) / install (golang). Is there a way I can do that build/install process before copying files over to the image? Ideally I'd only need to copy over the golang executable and reactjs production build.
Yes this is possible now using multi stage builds. The idea is that you can have multiple FROM in your docker file and your main image will be built using the last FROM. Below is a sample pseudo structure
FROM node:latest as reactbuild
WORKDIR /app
COPY . .
RUN webpack build
FROM golang:latest as gobuild
WORKDIR /app
COPY . .
RUN go build
FROM alpine
WORKDIR /app
COPY --from=gobuild /app/myapp /app/myapp
COPY --from=reactbuild /app/dist /app/dist
Please read below article for more details
https://docs.docker.com/engine/userguide/eng-image/multistage-build/