Skip to content
Majd Khalife edited this page Nov 9, 2024 · 22 revisions

What is Docker?

Docker is a tool that allows developers to package applications as well as their dependencies into containers. This container can run anywhere, and on any device, ensuring that the image behaves the same regardless of what OS it is being run on. This is especially useful so that we don't get the "it works on my computer, so it should work on yours" excuse.

How to install Docker

Mac/Windows

Install Docker Desktop here. Make sure you have the Docker Desktop app running when you want to use Docker.

Ubuntu

sudo apt install docker.io

Docker images vs Docker containers

Think of Docker images as a blueprint and containers as the objects created using that blueprint. The image includes all the instructions, code, and dependencies, while the container is a running instance of that image.

Dockerhub

Dockerhub is a website where people can share and download containers. A good way to think about it would be as an App Store - but for Docker images.

What does the docker compose command do?

Docker compose allows us to define multi container Docker applications using a single .yml file.
-docker compose up: Will start the containers defined in the compose.yml file.
-docker compose down: Stops and removes containers defined in the compose.yml file.

Docker run

docker run is the command used to start a container from an image.

Example: docker run hello-world

Docker exec

docker exec allows you to run commands inside a running container. This means that you can only run this command if the container is already running(which can be done by using docker run)

Example: Example: docker exec -it <container_name> bash opens a bash shell inside the running container.

Docker kill

docker kill forcefully stops a running container by sending a SIGKILL signal. It can be used when you need to stop a misbehaving container quickly.
Example: docker kill my_container

Docker commit

docker commit creates a new image from a container's current state. It's useful when you want to save changes made inside a container.
Example: docker commit my_container my_image

Docker push

docker push allows you to upload your image to Dockerhub.

Example: docker push username/image_name:tag

Docker Prune:

Over time, Docker keeps unused containers, images, and other data. To clean up and free space, you can use Docker prune.

docker system prune

Docker multi architecture build guide

This guide will walk you through the steps to ensure your Docker images are compatible across multiple platforms(arm64 and amd64 machines)

Before proceeding, make sure you're working with the latest version of the image by pulling it from Docker Hub.
Replace <image_type> with the appropriate tag docker pull mcgillrobotics/auv_2025:<image_type>

Next, make sure you have the buildx command installed by running
(*)docker buildx version
If its not installed, install it using brew(for macOS)

brew install docker-buildx

Then run (*) again to ensure that buildx is properly installed.

To create multi-platform images, you need to create a new buildx builder.
docker buildx create --name multi_architecture_builder --use
Ensure it's running correctly by listing all your active containers:docker buildx ls

Then go ahead and pull the latest image again to make sure everything is up to date: docker pull mcgillrobotics/auv_2025:<image_type>

Now, navigate to the directory where the Dockerfile is located, and run the following command to push build and push the image for both amd64 and arm64 docker buildx build --platform linux/amd64,linux/arm64 -t mcgillrobotics/auv_2025:<image_type> --push .

Now just repeat the process by navigating to the different Dockerfiles inside the Docker directory, pulling the latest images, and repeating step 4 by changing the <image_type>