This tutorials will walk you through how to build and push a container image to Docker Hub (Docker's public container registry) and then import it into Uffizzi.
Prerequisites
This tutorial assumes that you have already completed the following prerequisite steps:
Create a repository on Docker Hub
To create a repo:
-
Sign in to Docker Hub.
-
Click on Create Repository:
-
Name it <your-username>/my-first-repo as shown below. Select Private:
- Now that you've created a repo, you should see:
Download Docker Desktop and login
You’ll need to download Docker Desktop to build and push a container image to Docker Hub.
-
Download and install Docker Desktop. If on Linux, download Docker Engine - Community.
-
Open the terminal and sign in to Docker Hub on your computer by running
docker login
.
Build and push a container image to Docker Hub from your computer
Docker can build images automatically by reading the instructions from a Dockerfile
. A Dockerfile
is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build
users can create an automated build that executes several command-line instructions in succession.
- Start by creating a Dockerfile for your app. Below are some examples if you need help getting started.
- Example Dockerfile for Node.js
- Example Dockerfile for Python
- Example Dockerfile for React
- Example Dockerfile for Ruby
-
Run
docker build -t <your_username>/my-first-repo .
to build your Docker image. -
Run
docker run <your_username>/my-first-repo
to test your Docker image locally. -
Run
docker push <your_username>/my-first-repo
to push your Docker image to Docker Hub.
And in Docker Hub, your repository should have a new latest
tag available under Tags:
Link your Docker Hub account to Uffizzi
- Login to Uffizzi
- Create a new app environment
- At the Import your app step, select Docker Hub.
- On the next page, enter your Docker Hub credentials to link your account.
- Select your Docker image <your-username>/my-first-repo and select the
latest
tag. Then click Go to next step. - Configure your app by setting your HTTP port and any environment variables your app requires. Then click Go to next step.
- On the database selection page click Skip this step.
- Finally, review your selection and click Deploy Now.