Reputation: 53
import docker
# Initialize the Docker client
client = docker.from_env()
# Define Docker run options
docker_run_options = {
'name': 'container-name',
'user': 'dafoamuser',
'mounts': [
{
'type': 'bind',
'source': 'D:/Dafoam/oneraM6',
'target': '/home/dafoamuser/mount'
}
],
'working_dir': '/home/dafoamuser/mount',
'detach': True,
'tty': True,
'stdin_open': True,
'command': 'bash'
}
# Run the Docker container with specified options
container = client.containers.run(
'dafoamimage:latest',
**docker_run_options
)
# Execute the mpirun command inside the container
mpirun_command = 'mpirun -np 8 python runScript_v2.py 2>&1 | tee logOpt.txt'
exec_cmd = container.exec_run(mpirun_command, tty=True, privileged=True)
print(f"Command: {mpirun_command}\nOutput:\n{exec_cmd.output.decode('utf-8')}")
# Stop and remove the container (if needed)
container.stop()
container.remove()
I am trying to execute a python script named runScript_v2.py inside container's shell using the above python script. But I get the following error:
C:\Users\yesbo\.conda\envs\py39env\lib\site-packages\paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated
"class": algorithms.Blowfish,
Command: mpirun -np 8 python runScript_v2.py 2>&1 | tee logOpt.txt
Output:
--------------------------------------------------------------------------
mpirun was unable to find the specified executable file, and therefore
did not launch the job. This error was first reported for process
rank 0; it may have occurred for other processes as well.
NOTE: A common cause for this error is misspelling a mpirun command
line parameter option (remember that mpirun interprets the first
unrecognized command line token as the executable).
Node: c537205732b5
Executable: python
--------------------------------------------------------------------------
8 total processes failed to start
How can I fix this? From cmd I can run this mpirun command easily without any errors. But when I run my python script it gives me the error.
Upvotes: 0
Views: 79