Skip to content

MySQL Image Pulling

Usage

The MySQL pull command can be used for quickly pulling many databases that relate to a project's environment.

The following command will pull all the databases that are used for the dev environment.

$ skpr mysql image pull dev
Pulling: xxxxxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/example-project1/mysql:dev-default-latest

The output of the above command indicates the name of the Docker image which can be used with Docker Compose or other tools.

Alternative method: AWS CLI

Access to Skpr is handled with AWS IAM. Even though we provide our own way to do this, you're able to use the official AWS CLI tool to pull database images to your local development machine.

Skpr automatically sanitises developer database images, making them safe to use locally, for instance testing, offline image backups etc.

Installation

For installation instructions specific to your OS, refer to the official installation instructions on the AWS website.

Authentication

The first step in fetching these images is to authenticate with the registry, which you can safely pipe to the docker login subcommand.

Replace ${aws_account_id} and ${region} in the commands below with the values provided. You will need the following details:

  • aws_account_id
  • region

Windows

On Windows-compatible shells such as PowerShell, you need to run the following command:

(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin ${aws_account_id}.dkr.ecr.${region}.amazonaws.com

Linux/MacOS

On any non-Windows shell that is compatible, you can run the following command:

aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${aws_account_id}.dkr.ecr.${region}.amazonaws.com

Pulling the image

To pull the image you'll need some additional details including the following:

  • cluster
  • project
  • envionment

You'll need to run this command:

docker pull ${aws_account_id}.dkr.ecr.${region}.amazonaws.com/${cluster}-${project}/mysql:${environment}-default-latest

More Information

$ skpr mysql image pull --help
usage: skpr mysql image pull <environment> [<database>]

Pulls a database image associated with an environment.

Flags:
  --help  Show context-sensitive help (also try --help-long and --help-man).

Args:
  <environment>  Name of the environment.
  [<database>]   Name of the database

What's next?