Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We can't run the docker as we want #3

Open
celiale opened this issue Jul 27, 2021 · 3 comments
Open

We can't run the docker as we want #3

celiale opened this issue Jul 27, 2021 · 3 comments

Comments

@celiale
Copy link
Collaborator

celiale commented Jul 27, 2021

@jcfr

Hello Jean-christophe,

Thank you so much for your work. We have been looking at what you did those weeks and it's perfect.

However we still have one issue that we don't know how to solve.
In the dockerfile that you wrote: "L42: ENTRYPOINT bash --init-file /app/slicer-env.sh"
we understood that when the docker will be run, the first script that will be executed will be the slicer-env.sh bash script.

Our problem is that when we tried to run the following command line:
docker run --rm our_docker_name:latest bash /app/a_bash_script.sh --help
nothing happened.

We tried several approaches and the only one that worked is to copy all the paths in the slicer-env.sh into the dockerfile as ENV. But we don't think it's a "clean" solution.

So we have a couple of questions:

  • Is there a way to run a bash script even if there is a ENTRYPOINT inside the dockerfile script
  • Is there another way to create all the paths for the docker container

If you need more explanation and/or if you have time, we could schedule a meeting if you are available this week.

Thank you very much,
Sincerely,
Romain and Celia

@jcfr
Copy link

jcfr commented Jul 27, 2021

It is great you are making progress 💯
Also thank you for the detailed description.

Thank you so much for your work

Credits should go to @allemangD who spent the time to add the script and update the DockerFile.

Creating pull request

Your latest changes

I noticed you directly added few commits on top of the main branch. The problem is that these commits do not have a descriptive message and where not reviewed.

I suggest to do the following:

(1) Push your changes in a separate branch called clusterpost-integration. This can be done like this:

git clone git@github.com:DCBIA-OrthoLab/SlicerCMF-docker.git
git push origin main:clusterpost-integration

(2) Revert the main branch to remove the two commits:

git reset --hard HEAD~2
git push origin main --force

(3) Go to https://github.com/DCBIA-OrthoLab/SlicerCMF-docker and create a new pull request

Comments

In the dockerfile that you wrote: L42: ENTRYPOINT bash --init-file /app/slicer-env.sh
we understood that when the docker will be run, the first script that will be executed will be the slicer-env.sh bash script.

Our problem is that when we tried to run the following command line:
docker run --rm our_docker_name:latest bash /app/a_bash_script.sh --help
nothing happened.

To better answer the questions, could you describe where /app/a_bash_script.sh comes from. Is it a script already available in the image or a script living outside ?

@celiale
Copy link
Collaborator Author

celiale commented Jul 27, 2021

No problem, we will do it.

/app/a_bash_script.sh is a script that we will download in the dockerfile (RUN wget github/a_bash_script.sh), and that will run a slicer module, such as bone texture or histogram matching.

@allemangD
Copy link
Contributor

allemangD commented Jul 27, 2021

It is probably easiest to just manually source /app/slicer-env.sh from within a_bash_script.sh. You can see the necessary changes in https://github.com/allemangD/SlicerCMF-docker/commit/4f7c56ea413bd1f7c23ca09950bee2c71c2cb700

Usage in that case would look something like this:

$ docker run --rm cmf bash some-script.sh

My intent in using ENTRYPOINT with --init-file was to automatically set up the environment; however, I misunderstood that --init-file is ignored if bash is run non-interactively (as with executing a script). The only other way I know to achieve this is to modify ~/.profile and use bash --login. The only benefit may be that it would allow usage without a helper script:

$ docker run --rm cmf -c ComputeGLCMFeatures --help
$ docker run --rm cmf some_script.sh

I don't think there are any cons to that approach, except that some tools may have some strange behavior from running in a non-interactive login shell. If you're interested you can see those changes in https://github.com/allemangD/SlicerCMF-docker/commit/b98a5f8d67efd9c76cee7034bc17c6ad6d495b95.


I would recommend the first approach; just add source /app/slicer-env.sh to the top of a_bash_script.sh and remove ENTRYPOINT from the Dockerfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants