Preface

This blog post assumes:

For those unfamiliar with the above, here are some resources

Introduction

I prefer using Quay.io as my container registry instead of Dockerhub, and as such, I had to learn how setup Travis to push to quay.io. This is something I hadn’t done before, as I’ve only recently started making my own container images.

Step One: fork the tutorial repo

I’ve setup a repo on github that I’ll be using as a guide for this tutorial, it can be found here. All you need to do is press the Fork button:

fork button

This will make a copy of my repo for you to use with your account. The next step is to clone this repo:

git clone [email protected]:AdrianKoshka/travis-quay-tutorial.git

You can find the URL to clone from when you press the Clone or download button.

clone or download button

Step Two: Initial repo setup

You’ll need to edit the .travis.yml and docker_push files in your repo, replacing [yourusername] with the username of your quay account.

Step Three: Creating the quay repository

When signed into quay, in the upper right-hand corner, you’ll see a + Create New Repository button. Click the button,

quay plus button

You’ll want to select Public instead of Private, and enter the repository name. Then click Create Public Repository. You’ve now created the empty repository we’ll be pushing our container image to later.

quay new repo

Step Four: Creating the “Robot Account”

Robot accounts are “accounts” in quay.io under your user used for automated tasks.

Again, in the upper right-hand corner, you’ll see the + button, click it, then click New Robot Account.

New Robot Account

You’ll need to enter a name and description for the bot:

Create Robot Account Step 1

Press Create Robot Account, now you’ll have to give the robot write permissions to the repo you just created:

Give Robot privileges

Then press Add Permissions. You’ll be taken to your robot account settings page now.

Robot Settings Page

Click the username of your newly created bot, it should bring up a window with your bots username and password.

Bot username and password

We’ll need these creds later.

Step Five: Adding variables to your repo on travis

On Travis, go to your settings and click the sync account button. In the list of repositories should be your travis-quay-tutorial repo you forked earlier, activate it, and click on the settings button.

Travis Settings

Scroll down to the section named Environment Variables, and add a variable name QUAY_BOT_USERNAME, put the username of your robot account that you saw in the previous section, you should be able to copy-paste it.

Add QUAY_BOT_USERNAME

Press the Add button. Add another variable called QUAY_BOT_PASSWORD and enter your bots password.

Your Environment Variables section should look like this now:

Travis Environmental Variables After

Step Six: Committing the changes from step two

Now that you’ve set everything else up, you can commit your changes to .travis.yml and docker_push, then push your changes to your fork. This should trigger a build with travis, which will build the container, and then push it to the quay repository.

Resources