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
Logging into Docker
Logging out of Docker
Pulling an image named IMAGE from Docker Hub
List currently installed images
Rename a docker container
Start running a docker image IMAGE and execute the command echo
docker run IMAGE echo 'hello'
See if any processes are running
View all processes, whether active or finished
Start a docker container named CONTAINER based on the image named IMAGE, specifying a name for the container
docker run \
--name CONTAINER \
--interactive \
--tty IMAGE \
/bin/bash
Continue running the container named CONTAINER that you previously exited
Execute a command on a currently running docker container named CONTAINER
docker exec --interactive --tty CONTAINER '/bin/bash'
Stop a container named CONTAINER
Kill a running container
container_id='384bf99f07c8'
docker container kill ${container_id}
List the currently running containers
# [ Short Form ]
docker ps
# [ Long Form ]
docker container ls
List all containers
Remove a container named CONTAINER (not the image that created it)
Removing an image named IMAGE from the local machine
Building an image named IMAGE from a Dockerfile
docker build . \
--tag 'USERNAME/IMAGE' \
--squash
Publication
A few additional steps are required to publishing a container to GitHub's container registry.
SSH Connections
- As represented in a
compose.yaml file
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*:

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:
Removing a Podman machine:
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 .