-2

Hey I try to automatical creat a docker container with this code

    clone = 'git clone ' + link
    print(clone)
    run = 'python3 ' + dateiname
    print(run)
    dockers = docker.from_env()
    userdocker = dockers.containers.run(
        image='python:3-alpine', stdout=True, name=author_name, command=[clone, run])
    log = userdocker.logs()
    print(log)

but I aslo get this error Internal Server Error ("OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "git clone ": stat git clone : no such file or directory: unknown")

Is ther any way to fix this or is there another way?

2 Answers2

0

git is not installed in the container. git It should be installed with apk add git before it can be used.

Try to build new container with git based on the python:3-alpine.

Create Dockerfile as follows

FROM python:3-alpine

RUN apk update && apk add git

Build the image

docker build -t mypython:3-alpine .

Then use this image instead of python:3-alpine.

jordanvrtanoski
  • 5,104
  • 1
  • 20
  • 29
  • Should I add it as a command as it doesn't work or by some other way I couldn't find – Martin Beneder Mar 01 '21 at 14:29
  • before executing the `git clone`. Either create new image that includes the `git` or add it before calling `git clone` as by example `clone = 'apk update && apk add git && git clone ' + link` – jordanvrtanoski Mar 01 '21 at 14:46
0

I found also aut that I shouldn't use [] for a command here a link for more info