My Dockerfile looks like this:
FROM ubuntu:20.04
RUN apt update
RUN apt install -y libpq-dev python3-dev python3-pip
ENTRYPOINT /APP
RUN mkdir -p /APP/OUTPUT
COPY . .
RUN pip3 install -r requirements.txt
CMD ["python3" "Main.py"]
But when i run the container, i get the following message:
/bin/sh: 1: /APP: Permission denied in Ubuntu Docker container
What am i doing wrong?
Related
FROM ubuntu:focal
WORKDIR /admin-flask
COPY . /admin-flask
# set environment variables
# ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV FLASK_APP run.py
VOLUME . /var/wwww
RUN apt update -y && apt upgrade -y
RUN apt autoremove -y
RUN apt install python3 -y && apt install python3-pip -y
RUN pip install virtualenv
RUN virtualenv env
RUN chmod +x run.py
# install python dependencies
RUN /admin-flask/env/bin/pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
# gunicorn
#CMD ["gunicorn", "--config", "gunicorn-cfg.py", "run:app"]
CMD ["/admin-flask/env/bin/gunicorn","--config", "gunicorn-cfg.py", "run.py"]
failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container
init: open /dev/ptmx: no such file or directory: unknown.
ERRO[0004] error waiting for container:
Trying to build a local Docker file, getting this error when running a container
Why Docker image build is getting failed when build with - ?
Host Details
- docker desktop community 2.1.0.5 for Windows
- Windows 10
Dockerfile:
FROM ubuntu:latest
MAINTAINER "rizwan#gm.com"
RUN apt-get update \
&& apt-get install -y python3-pip python3-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
WORKDIR /app
COPY . /app
COPY requirements.txt /app/requirements.txt
RUN pip3 --no-cache-dir install -r requirements.txt
EXPOSE 5000
CMD ["python3", "my_service.py","--input-path= /input.csv", "--output-path=/output.csv"]
Folder Structure
-Root
-Application.py
-Dockerfile
-requirements.txt
COMMAND
- Failing : docker build - < Dockerfile
Message: ERROR: Could not open requirements file: [Errno 2] No such
file or directory: 'requirements.txt'
- Successful: docker build .
When you run
docker build - < Dockerfile
it sends only the Dockerfile to the Docker daemon, but no other files. When you tell Docker to COPY a file into the image, you haven't actually sent it the file. It's very similar to including everything in your source tree in the .dockerignore file.
Typically you'll send Docker the current directory as the context directory instead:
docker build . # knows to look for Dockerfile by default
I'm trying to build a Docker image on Ubuntu 20.04 WSL for Windows 10 and keep running into the following error when Docker gets to the step to run pip3 install:
/bin/sh: 1: pip3: not found
The command '/bin/sh -c pip3 install -r /tmp/requirements.txt' returned a non-zero code: 127
The Dockerfile is:
FROM ubuntu:20.04
COPY bots/art_print.py /bots/
COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt
WORKDIR /bots
CMD ["python3", "art-print-bot"]
I've uninstalled and reinstalled pip3 and verified that it is there with $ which pip3
/usr/bin/pip3
Any ideas as to why the Docker build is not recognizing pip3?
Looks like you may have an issue with your PATH environment variable. Try changing the pip RUN line to:
RUN python3 -m pip install -r /tmp/requirements.txt
I am trying to install grafana in docker container but getting permission denied error. Below are the details :
sudo docker build -t grafana:latest .
Sending build context to Docker daemon 5.12 kB
Step 1/8 : FROM grafana/grafana:6.3.5
---> 2017e1eb54fa
Step 2/8 : RUN apt-get update && apt-get install -y curl gettext-base && rm -rf /var/lib/apt/lists/*
---> Running in 4c3b0835bb22
Reading package lists...
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
The command '/bin/sh -c apt-get update && apt-get install -y curl gettext-base && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
I have tried running it using sudo but that didn't work. Also I have tried
RUN sudo apt-get update && apt-get install -y curl gettext-base && rm -rf /var/lib/apt/lists/*
but this also didn't work.
Below is the dockerfile
FROM grafana/grafana:6.3.5
RUN apt-get update && apt-get install -y curl gettext-base && rm -rf /var/lib/apt/lists/*
WORKDIR /etc/grafana
COPY datasources ./datasources
WORKDIR /app
COPY entrypoint.sh ./
RUN chmod u+x entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
try this:
FROM grafana/grafana:6.3.5
USER root
RUN apt-get update && apt-get install -y curl gettext-base && rm -rf /var/lib/apt/lists/*
USER grafana
WORKDIR /etc/grafana
COPY datasources ./datasources
WORKDIR /app
COPY entrypoint.sh ./
RUN chmod u+x entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
the image use the default user: grafana
You can try docker commit to make your changes permanent. it's easier than build a new image with dockerfile.
first you should go inside container, then make your changes like upgrading or changing configs and finally commit changes.
host$ docker exec -it "container_name/id" bash
container# apt-get update
host$ docker commit "container_name/id" my-grafana
You can see image list with docker image ls
I'm trying to install apach2, libapache2-mod-wsgi-py3 and openssl in the container. I've removed some packages and fix typos in Dockerfile but the error is still there.
When i run docker-compose build my setup is running ok, until it hit the part in the Dockerfile where I'm initializing this install and I've got this error:
E: Unable to locate package RUN
E: Unable to locate package apt-get
E: Unable to locate package install
ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y apache2 libapache2-mod-wsgi-py3 curl dpgk-sig RUN apt-get install -yq openssh-server' returned a non-zero code: 100
You can check the whole installation process here, and this is my Dockerfile:
FROM ubuntu:16.04
FROM python:3.5
ENV PYTHONUNBUFFERED 1
RUN cat /etc/passwd
RUN cat /etc/group
RUN apt-get update && apt-get install -y \
apache2 \
libapache2-mod-wsgi-py3 \
RUN apt-get install -y openssl
RUN mkdir /var/run/sshd
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code
EXPOSE 80
ADD config/apache/000-default.conf /etc/apache/sites-available/000-default.conf
ADD config/start.sh /tmp/start.sh
ADD src /var/www
RUN chown -R root:www-data /var/www
RUN chmod u+rwx,g+rx,o+rx /var/www
RUN find /var/www -type d -exec chmod u+rwx,g+rx,o+rx {} +
RUN find /var/www -type f -exec chmod u+rw,g+rw,o+r {} +
#essentially: CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
CMD ["/tmp/start.sh"]
Can someone explain me why is this happening, and how to fix it, thanks.
Your problem is this line:
libapache2-mod-wsgi-py3 \
The \ is a continuation and the next thing it sees is RUN so is treating that like a package (which it can't find). Lose the \ and it should work fine.