Use DockerHub images
To use a private DockerHub image in Lightning AI, give it a read-only token.
Push a container
Use this demo to get an image into DockerHub if you don't have one yet. Pushing needs a token with Read & Write permissions.
Go to your DockerHub personal access tokens page: https://app.docker.com/settings/personal-access-tokens
Generate a new token with "Read & Write" permissions and copy it.
Log in, push an
nginximage to your account, and pull it back.docker loginasks for the token as the password.# login docker login -u <dockerhub-username> # pull test image (or use your own) docker pull nginx:latest # tag docker tag nginx:latest <dockerhub-username>/nginx-test:latest # push docker push <dockerhub-username>/nginx-test:latest # pull docker pull <dockerhub-username>/nginx-test:latestA repository created by a push is public by default. Make it private in DockerHub, so the run demo tests the credential.
Run the container in a job or a deployment
Lightning AI only needs to pull the image, so the token only needs read-only permissions.
Create a read-only token
Go to your DockerHub personal access tokens page: https://app.docker.com/settings/personal-access-tokens
Generate a new token with "Read-only" permissions:

- Copy the generated token:

Run it as a job
Create the DockerHub credential as a teamspace secret, then pass its name as image_credentials:
- Open your teamspace's settings and click Secrets.
- Click New Secret, then select the Credential tab.
- Enter a Name, for example
dockerhub. - In Username, enter your DockerHub username. In Password, paste the read-only token.
- Click Create.
from lightning_sdk import Job, Machine, Teamspace
teamspace = Teamspace(name="my-teamspace", user="my-user")
submitted_job = Job.run(
name="my-job",
command="cat /etc/os-release",
image="<dockerhub-username>/nginx-test:latest",
machine=Machine.CPU,
teamspace=teamspace,
image_credentials="dockerhub",
)See Submit jobs for all the job options.
Run it as a deployment
When starting a deployment, enter <dockerhub-username>/nginx-test:latest as the image. Click on the registry credentials and specify the DockerHub username and the generated token as your password. Then click "Deploy".

Was this page helpful?
Thanks for the feedback.