Run docker containers
You can run arbitrary docker containers as jobs within your metapage workflows.
These steps need to be set up only once, then you can run any docker image.
The public docker work queue service is currently for testing/demonstration purposes. Do not publicly share these workflows as others to run arbitrary docker containers on your infrastructure.
This service will soon be replaced with one secure for teams.
Run python via a docker container on your own computer
Requires familiarity with the command line terminal
Host requirements:
Steps (from https://docker.mtfm.io/#?tab=6):
1. Generate a uuid for the job queue
uuid
If your terminal does not have this program, go to this page and copy the uuid: https://www.uuidgenerator.net/version4
2. Take the uuid generated, and start the worker process
Replace <uuid>
with your generated one above
docker run --restart unless-stopped -tid -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp metapage/metaframe-docker-worker:0.1.2 --cpus=2 --queue=<uuid>
Now your local machine will run docker images on this unguessable queue.
Do not share this queue id, and do not publicly share workflows using this queue id.
3. Add a docker metaframe to your metapage
Create a new metapage:
Click “Edit” for edit mode
The metapage will initially be empty
This is how you can add metaframe components.
Add the “Run Docker Container Jobs” metaframe
Search for the docker metaframe, type “docker” in the search field, you should see something like:
Add the “Run Docker Container Jobs” metaframe, click on the “+ Add” button next to it
Switch to “View” mode
You can directly configure the metaframe this way
Add your queue id
Now time to add your queue id. Click on “Queue” the “Queue Key”
Enter in the uuid
from above.
Congratulations! Now your local machine will run any docker containers you want.
4. Configure the docker container frame
Set the docker image to python
Set:
image:
czentye/matplotlib-minimal:3.1.2command:
python3 /inputs/run.py
Add a python script
Click the inputs tab
Click the +
and name the new file run.py
Edit the python script
Copy the script and save
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
ys = 200 + np.random.randn(100)
x = [x for x in range(len(ys))]
plt.plot(x, ys, '-')
plt.fill_between(x, ys, 195, where=(ys > 195), facecolor='g', alpha=0.6)
plt.title("Sample Visualization")
# plt.show() # save instead of show because we are headless
plt.savefig('/outputs/plot.png')
print("Created image and sent!")
5. Add an image viewer to see the docker output
Edit mode
Search for “Image Viewer” and add
Edit the Image Viewer
Click “Show Image” and “Connect”
Connect all outputs to inputs
*
means all.
6. Congrats you have generated an image
Do you want to save the image? See →