I am trying to run a script inside the docker container.
I tried using docker cp
but it does not work as there are no running containers. docker container ls
is empty.
Locally I am able to docker cp my-custom-image:my_script.py my_script.py
so the problem is not with my docker image.
stage-name:
image: "my-custom-image:0.1.0"
stage: my-stage
script:
- python3 my_script.py
I finally found the solution
In the dockerfile of my-custom-image
, I added these lines
COPY ./my_script.py /usr/local/bin/my_script.py
RUN chmod +x /usr/local/bin/my_script.py
I added python3 shebang in my_script.py
#!/usr/local/bin/python3
Then I am able to execute the script in the CI
stage-name:
image: "my-custom-image:0.1.0"
stage: my-stage
script:
- my_script.py
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.