This is the Dockerfile:
FROM lambci/lambda:build-python3.6
# Copy in your requirements file
ADD requirements.txt /requirements.txt
# Copy your application code to the container
RUN mkdir /code/
WORKDIR /code/
ADD . /code/
ENV PS1 'zappa#$(pwd | sed "s#^/var/task/\?##")\$ '
ADD zappa_settings.json /var/task/zappa_settings.json
WORKDIR /var/task
RUN virtualenv /var/venv && \
source /var/venv/bin/activate && \
pip install -U pip zappa && \
pip install -r /requirements.txt && \
deactivate
CMD ["zappa"]
However, when I run docker-compose up I get:
Recreating basesite_web_1 ...
Recreating basesite_web_1 ... error
ERROR: for basesite_web_1 Cannot start service web: oci runtime error: container_linux.go:262: starting container process caused "exec: \"zappa\": executable file not found in $PATH"
ERROR: for web Cannot start service web: oci runtime error: container_linux.go:262: starting container process caused "exec: \"zappa\": executable file not found in $PATH"
ERROR: Encountered errors while bringing up the project.
I assume it's because I need to activate the virtualenv. I want to be able to run the project on my local machine for development. What am I missing? Thanks!
Related
I am trying to build this dockerfile and then run it but I'm getting this error docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./deployment-service": permission denied: unknown.
This is my docker file, I've created the volumes and networks
FROM golang:1.19.2-alpine as builder
RUN apk add bash
RUN apk add --no-cache openssh-client ansible git
RUN mkdir /workspace
WORKDIR /workspace
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY . ./
RUN go build -o deployment-service cmd/deployment-service/main.go
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /workspace .
ARG DEFAULT_PORT=8080
ENV PORT $DEFAULT_PORT
EXPOSE $PORT
CMD ["./deployment-service"]
this is my run command,
docker run --name=${CONTAINER_NAME} -d --rm -p ${PORT}:80 -e DEPLOYMENT_SERVICE_DATABASE_CONNECTION_URI=mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}#${MONGO_CONTAINER_NAME}:27017/ -e DEPLOYMENT_SERVICE_SERVER_SECRET_KEY=${SECRET_KEY} -e ANSIBLE_CONFIG='./jam-ansible/ansible.cfg' -e DEPLOYMENT_SERVICE_ANSIBLE_SUBMISSION_ROOT=${DEPLOYMENT_ROOT} -v ${DEPLOYMENT_VOLUME}:${DEPLOYMENT_ROOT} --network=${NETWORK_NAME} server:latest
help to get my issue solved.
looks like you need to edit the permissions of the deployment-service file.
try running
chmod a+x ./deployment-service
in the terminal then trying again.
Sometimes you may end up getting this error because you have not specified an entrypoint for your container.
You can do that using ENTRYPOINT inside the Dockerfile
Below is a .NET example:
ENTRYPOINT ["dotnet", "application.dll"]
It seems lack of permission to execute deployment-service. You can add
RUN chmod +x deployment-service
before CMD ["./deployment-service"]
In my case, I got the below error while trying to run the container using the command:
docker container run -p portnumber:portnumber amazoncorretto:17-alpine-jdk
ERROR:
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown.
I used amazoncorretto:17-alpine-jdk docker image and in dockerfile instead of bash, I changed it to sh and it worked as bash didn't work with alpine.
Command changed from:
CMD ["bash", "-c", "java -jar test.jar"]
to:
CMD ["sh", "-c", "java -jar test.jar"]
After some help I succeded to build the image of my Java Application and then able to run it in a container. Now I would like to add ExpressVPN inside the same container and wounder how do I do that? I can see that on DockerHub their is some polkaned/expressvpn with connection to Github to see all the files
Is it possible to just copy the code from the Dockerfile (of polkaned) and add it to my Dockerfile? Then I have understood that I will have to use somekind of script file in my Entrypoint instead where I state the commands and information that needs to get ExpressVPN running.
I have tried but failed. This is how I did:
FROM debian:bullseye-slim
ENV ACTIVATION_CODE Code
ENV LOCATION smart
ENV PREFERRED_PROTOCOL auto
ENV LIGHTWAY_CIPHER auto
ARG APP=expressvpn_3.18.1.0-1_amd64.deb
RUN apt-get update && apt-get install -y --no-install-recommends \
libterm-readkey-perl ca-certificates wget expect iproute2 curl procps libnm0 \
&& rm -rf /var/lib/apt/lists/* \
&& wget -q "https://www.expressvpn.works/clients/linux/${APP}" -O /tmp/${APP} \
&& dpkg -i /tmp/${APP} \
&& rm -rf /tmp/*.deb \
&& apt-get purge -y --auto-remove wget
COPY entrypoint.sh /tmp/entrypoint.sh
COPY expressvpnActivate.sh /tmp/expressvpnActivate.sh
#
# Build stage
#
FROM maven:3.8.4-openjdk-17 AS build
COPY src /test/src
COPY pom.xml /test
#RUN mvn -f /test/pom.xml clean package
RUN mvn -f /test/pom.xml clean package
#
# Package stage
#
FROM openjdk:17-alpine
COPY --from=build /test/target/test-0.0.1-SNAPSHOT.jar /usr/local/lib/test.jar
ENTRYPOINT ["/bin/bash", "/tmp/entrypoint.sh"]
An image is created but when I try to start it I get the following error:
Error invoking remote method 'docker-run-container': Error: (HTTP code 400) unexpected - OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin": permission denied: unknown
I change entrypoint to /bash and got this:
Error invoking remote method 'docker-run-container': Error: (HTTP code 400) unexpected - OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "bash": executable file not found in $PATH: unknown
then I removed /bin/bash and got this:
Error invoking remote method 'docker-start-container': Error: (HTTP code 400) unexpected - OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/tmp/entrypoint.sh": stat /tmp/entrypoint.sh: no such file or directory: unknown
What I really want to complete is that I in the end would like to be able to run "docker run .."
and then ExpressVPN should start and my Java Application should start after ExpressVPN have connected in the same container. Is this possible?
I'm trying to run an containerized image locally using google cloud shell docker daemon:
> PORT=8080 && docker run -p 9090:${PORT} -e PORT=${PORT} gcr.io/gbl-tpd-endetec-dev1/simplest-helloworld
However i got this error :
> docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"app.py\": executable file not found in $PATH": unknown.
ERRO[0001] error waiting for container: context canceled
When I check container status and in the COMMAND column, i don't have what i expect :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
977b0ee4b04d gcr.io/gbl-tpd-endetec-dev1/simplest-helloworld "app.py" 11 minutes ago Created 0.0.0.0:9090->8080/tcp youthful_williams
I should have "python ./app.py" since I've written it in my Dockerfile CMD instruction :
# Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.7-slim
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8080
CMD ["python", "./app.py"]
Can someone help me about what I am missing?
I am trying to run my docker image, but I am receiving the following error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"python3\": executable file not found in $PATH": unknown.
ERRO[0000] error waiting for container: context canceled
Here is my Dockerfile:
FROM python:3.6-alpine3.7
RUN apk add --no-cache python3-dev \
&& pip3 install --upgrade pip
RUN apk add --no-cache --update \
python3 python3-dev gcc \
gfortran musl-dev
RUN apk add --no-cache libressl-dev musl-dev libffi-dev
RUN python3.6 -m pip install --upgrade pip
RUN apk --no-cache add git
RUN apk add mariadb-dev
WORKDIR /socialworks-api
COPY . /socialworks-api
RUN pip3 --no-cache-dir install -r requirements.txt
ENV PATH="/opt/gtk/bin:$env/development.env"
EXPOSE 5000
ENTRYPOINT ["python3"]
CMD ["app.py"]
I think the issue might be with the ENV PATH which I set. I have also tried setting it to:
ENV PATH="/opt/gtk/bin:${env/development.env}"
But I would receive the following error when building my dockerfile:
Step 11/14 : ENV PATH="/opt/gtk/bin:${env/development.env}"
failed to process "\"/opt/gtk/bin:${env/development.env}\"": missing ':' in substitution
Without setting the environment, my application won't run.
I have also tried running on my dockerfile this command:
RUN export $(grep -v '^#' ./env/development.env | xargs)
It build successfully, but when I enter this command to the terminal:
docker run -it flaskapp
I am receiving an error that it still unable to locate the env variables.
$ docker run -it flaskapp
Traceback (most recent call last):
File "app.py", line 11, in <module>
app.config.from_object("config.Config")
File "/usr/local/lib/python3.6/site-packages/flask/config.py", line 174, in from_object
obj = import_string(obj)
File "/usr/local/lib/python3.6/site-packages/werkzeug/utils.py", line 568, in import_string
__import__(import_name)
File "/socialworks-api/config.py", line 4, in <module>
class Config(object):
File "/socialworks-api/config.py", line 5, in Config
MYSQL_HOST = os.environ['MYSQL_HOST']
File "/usr/local/lib/python3.6/os.py", line 669, in __getitem__
raise KeyError(key) from None
KeyError: 'MYSQL_HOST'
In your Dockerfile you specify
ENV PATH="/opt/gtk/bin:$env/development.env"
When you later run python3, the system looks in only these two directories, and when there's not a Python there, you get the error you see. It's probably in /usr/bin/python3, but the directory /usr/bin isn't in $PATH.
The simplest answer here is to delete this line entirely. Your Dockerfile creates neither a /opt/gtk nor a /development.env directory, so there's no files in either path that could be executed. If you do need to install custom software, putting it in a directory that's in the default system path (like /usr/local/bin) is a good approach.
If you do need to keep this line, make sure the existing $PATH stays as part of the value.
ENV PATH="/opt/gtk/bin:$PATH"
(Don't specify ENTRYPOINT ["python"]; combine this into a single CMD ["python3", "app.py"]. I'd encourage you to run docker run --rm -it yourimage /bin/sh to look around the filesystem and run debugging commands like env, but the ENTRYPOINT declaration breaks this use, and having the script file named in the CMD means it's still not the "container-as-command" pattern.)
I have been trying to get my application working - but I keep getting an error:
Task Stop Reason: Essential container in task exited; Container myapp Status Reason: CannotStartContainerError: API error (400): OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"docker-compose up\": executable file not found in $PATH": unknown
My Dockerfile:
FROM node:9.10.0
COPY / /myapp
WORKDIR /myapp
RUN chown -R node:node /myapp
USER node
RUN mkdir /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
RUN npm install -g #angular/cli
RUN npm install
USER root
ENV USER root
RUN apt-get update && \
apt-get install -y \
python \
python-dev \
python-pip \
python-setuptools \
&& pip install --upgrade awscli \
&& apt-get clean
Now my task definition (deploy.yaml) is pretty simple and a part of it is:
....
task:
taskRole: "<role>"
containerDefinitions:
- command:
- "docker-compose up"
...
When deploying the app, ECS normally runs docker run I assume, while I need docker-compose up to start my services (in docker-compose.yaml). Where do I run this command, or how do I fix this path?
If you look closer to the error message :
starting container process caused "exec: \"docker-compose up\": executable file not found in $PATH": unknown
You notice that Docker is trying to find an executable named "docker-compose up" in PATH. This is probably incorrect,it should have looked for a "docker-compose" executable (note the missing "[space] up" in exe path).
This is probably caused by a wrong "-command" YML properties.
You should have something like :
...
-command :
-docker-compose
-up
I experienced the same problem with the ENTRYPOINT command in the Dockerfile :
ENTRYPOINT ["command with parameters"]
is invalid. You must have
ENTRYPOINT ["command", "with", "parameters"]