简体   繁体   中英

Modify Python scripts from DockerFile

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.

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM