Docker Installation and Setup
Posted on: January 24, 2024
This blog will go through the complete process of installing and setting up Docker, exploring the basics of Docker images and containers. It also demonstrates how to create and manage containers with a practical example: containerizing the open-source ORB-SLAM3.
What is Docker?
Docker is a platform that allows you to package an application and its dependencies into a container. This ensures software runs consistently across environments — your laptop, a colleague’s computer, or a remote server.
Installing Docker
The installation process varies by operating system:
- Linux (Ubuntu example):
sudo apt-get update sudo apt-get install docker.io - Windows & macOS: Download Docker Desktop from the official website.
Verify installation with:
docker --version
Images and Containers
A Docker image is like a blueprint, and a container is the running instance. For example:
docker run -it ubuntu bash
Your First Container
Here’s a simple Dockerfile for a Python app:
FROM python:3.9
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "main.py"]
Build and run it with:
docker build -t my-python-app .
docker run my-python-app
Example: Containerizing ORB-SLAM3
ORB-SLAM3 is a powerful open-source SLAM system. Instead of manually installing dependencies, Docker makes it portable.
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
build-essential cmake git libopencv-dev
RUN git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git /opt/ORB_SLAM3
WORKDIR /opt/ORB_SLAM3
RUN mkdir build && cd build && cmake .. && make -j4
CMD ["/bin/bash"]
Build and run:
docker build -t orb-slam3 .
docker run -it orb-slam3
Conclusion
Docker simplifies installation, ensures reproducibility, and makes sharing research easier. By containerizing software like ORB-SLAM3, you can avoid compatibility headaches and focus on development. This post covered the basics — in future entries, I’ll dive into more advanced Docker concepts and use cases.