Docker

Docker is a really cool technology. If you need a video tutorial to jump in and get started, Peter McKee, a senior software engineer at Docker made a great video to help you get started with Docker. To learn more, watch Michael Irwin's talk at DockerCon 2019, "Containers for Beginners" the first installment of Docker's "Docker 101" series on YouTube.

Liz Rice's talk on creating Docker containers from scratch

Getting Started

Open the application in the menu bar to have Docker run its initial configurations, and then log in to the docker hub. From here, you're all set up and can proceed to use Docker from the command line.

Command Line Operations

Publication

A few additional steps are required to publishing a container to GitHub's container registry.

SSH Connections

version: '3'
services:
  my_service_name:
    build: .
    environment:
      - SSH_AUTH_SOCK="${SSH_AUTH_SOCK}"
    volumes:
      - ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}
docker run \
    --rm \
    --tty \
    --interactive \
    -v ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK} \
    --env SSH_AUTH_SOCK=${SSH_AUTH_SOCK} \
    CONTAINER_TAG

Docker Run


Podman

Me: "Mom, can we get Docker containers?" open-source

Mom: "No honey, we already have containers at home."

*containers at home*:

Podman Logo

Setting up AWS Elastic Container Registry

Stole this from a question on Stack Overflow

Getting the AWS account & region:

AWS_PROFILE='default'
AWS_ACCOUNT=$(
    aws sts get-caller-identity \
        --query 'Account' \
        --output 'text'
)
AWS_REGION=$(aws configure get region)

Authenticating to Amazon Elastic Container Registry (ECR):

aws \
    --region AWS_REGION \
    ecr get-login-password \
    | podman login \
        --password-stdin \
        --username 'AWS' \
        AWS_ACCOUNT.dkr.ecr.AWS_REGION.amazonaws.com

Creating a Podman machine:

podman machine init --cpus=0 --memory=4096 --now

Starting a Podman machine:

podman machine init
podman machine start

Stopping a Podman machine:

podman machine stop

Removing a Podman machine:

podman machine rm

Adding the AWS CLI to a Docker image

The hard part about it is getting it to be architecture agnostic, so that it works regardless of whether you are running on an x86_64 or arm64 architecture.

FROM public.ecr.aws/docker/library/python:3.10

RUN \
    curl "https://awscli.amazonaws.com/awscli-exe-linux-$(arch).zip" -o "awscliv2.zip" \
    && unzip awscliv2.zip \
    && ./aws/install --install-dir /opt/awscli --bin-dir /usr/local/bin \
    && rm -rf awscliv2.zip

ENTRYPOINT ["/bin/bash"]

You can build this image for multiple architectures, and push it to a remote registry, all in a single step:

docker buildx build \
    --platform='linux/amd64,linux/arm64' \
    --tag 'USERNAME/IMAGE' \
    --file='Dockerfile' \
    --push .