Skip to content

Docker CLI (+ docker-credential-pass)

Installation

Below are instructions for installing the docker CLI on Ubuntu. For other distros, or more up-to-date instructions, see the official docs.

Install (Ubuntu)

# Remove any old docker packages
sudo apt remove docker docker-engine docker.io containerd runc

# Add docker repo
sudo apt update
sudo apt install ca-certificates curl gnupg lsb-release
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install docker
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Add docker group, add user to docker group, change group
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

# Run a test container
docker run hello-world

Basic Use

Login

docker login [URL] # Prompts for Username and Password

⚠️ Without docker-credential-helpers, credentials will be stored as plaintext. (See docker-credential-helpers)

Build an image

ℹ️ NOTE: {IMAGE_TAG} == {REGISTRY_URL}/{OWNER}/{PROJECT_NAME}:{VERSION_NUMBER}

Prerequisites

  1. Have a valid Dockerfile in the project root. (See Docker)
  2. Current working directory is project root.

Command

docker build {PROJECT_ROOT} -t {IMAGE_TAG}

Publish an image

Prerequisites

  1. The image must be built and locally registered to the docker daemon. (If you ran the build command [above], then you're good.)

Command

docker push {IMAGE_TAG}