1

I am working in a distributed environment with separate docker containers. Each docker container is basically a neural network deployed in a pipeline.

I have a particular case in which I am using some external dependencies for my neural network that I install inside my Docker Container at a specific path.

When I want to change my hyperparameters for training the network, I have to manually search the location of the installed dependencies and modify some parameters inside the scripts belonging to those dependencies, due to the fact that the library that I am currently using hardcodes some values behind the scenes.

My question is the following: Is there a way to write some specific snippets in the Dockerfile in order to automatically modify those .py scripts installed in the Docker Container, given a specific path of their location? And if I can do such a thing, how?

An alternative that came into my mind right now would be to copy to the host the file that needs to be modified, modify it according to my needs, and then copy it back at the exact location from where it came; however I thought that there may be something more elegant.

2
  • 1
    Preferably read the "some parameters" from environment variables instead. Commented Mar 16, 2020 at 13:44
  • Since you mentioned in a comment that it is a little more complex, have you considered using docker volumes/mounts? From the sound of it you might be creating a way to complex structure for yourself. It is a bit hard to guess given the limited amount of information. Normally you would want to run docker with information you can determine up front, where only the output is unpredictable. Commented Mar 18, 2020 at 11:14

1 Answer 1

2

In short I think (like AKX mentioned in the comments) that you may want to use environment variables in your container. The following SO question describes how to do so using python: docker env for python variables

These can be set in the dockerfile before building and provided on running the container.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I am upvoting your answer since it is indeed useful. However, the use-case I was talking about is more complicated than this.
Thanks for that. Too bad I couldn't solve this for you though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.