-
Notifications
You must be signed in to change notification settings - Fork 3
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.
Install Docker Desktop here. Make sure you have the Docker Desktop app running when you want to use Docker.
sudo apt install docker.io
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 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.
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
is the command used to start a container from an image.
Example: docker run hello-world
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
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
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
allows you to upload your image to Dockerhub.
Example: docker push username/image_name:tag
Over time, Docker keeps unused containers, images, and other data. To clean up and free space, you can use Docker prune.
docker system prune
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>