gogasca
gogasca

Reputation: 10058

How to run shell script during Docker run

I got an existing Docker container. I need to run a shell script inside of it:

Now I need to access via shell and run commands manually:

nvidia-docker run --publish 127.0.0.1:8080:8888 -it gcr.io/project/container:latest bin/bash

and then

cd folder/demo/folder2
python demo.py -m "./data/mydata" -o ./lalala.engine -c ./data/dadada/
jupyter lab --ip=0.0.0.0 --allow-root

How can I start container and run commands without having to do it manually.

Upvotes: 1

Views: 241

Answers (1)

Sunny Pelletier
Sunny Pelletier

Reputation: 379

Create your own docker image (Dockerfile) by using the nvidia-docker as base image and then override the entrypoint with a custom script.

FROM nvidia-docker
COPY ./script.sh /scripts/script.sh
ENTRYPOINT /scripts/script.sh

and in script.sh do:

cd folder/demo/folder2
python demo.py -m "./data/mydata" -o ./lalala.engine -c ./data/dadada/
jupyter lab --ip=0.0.0.0 --allow-root

# Watever else you want
``

Upvotes: 1

Related Questions