— AI, MLOps, Linux — 1 min read
In this technical notes, I'll walk through the process of setting up an Ubuntu server to host Docker Compose services. This setup includes installing Docker, configuring the NVIDIA Container Toolkit (if required for GPU-based workloads), and running a sample service with Docker Compose.
Before start, ensure you have the following:
First, connect to your server via SSH and update the package list. It's always a good practice to ensure your system is up-to-date.
1sudo apt update2sudo apt upgrade -y
Docker is a platform that allows you to build, ship, and run applications in lightweight containers. To install Docker, use the official installation script:
1curl -fsSL https://get.docker.com -o get-docker.sh2sudo sh get-docker.sh
After installation, add your user to the docker
group so you can run Docker commands without sudo
:
1sudo usermod -aG docker $USER
Apply the group changes by logging out and logging back in, or use:
1su - $USER
Verify the Docker installation:
1docker --version
If your service requires GPU acceleration, install the NVIDIA Container Toolkit.
1curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \2 && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \3 sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \4 sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
1sudo apt-get update2sudo apt-get install -y nvidia-container-toolkit
nvidia-docker2
:1sudo apt-get install -y nvidia-docker2
1sudo systemctl restart docker
Docker Compose simplifies the process of defining and running multi-container Docker applications. Install it as follows:
1sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Make the binary executable:
1sudo chmod +x /usr/local/bin/docker-compose
Verify the installation:
1docker-compose --version
Navigate to the directory containing your docker-compose.yml
file. This file defines the services for your application. Build the Docker images:
1cd /path/to/your/project2docker-compose build
Start your service with Docker Compose:
1docker-compose up -d
Check the running containers:
1docker-compose ps
We now have a fully functional Ubuntu server configured to run Docker Compose services. With this setup, you can deploy microservices, web applications, and other containerized workloads efficiently. If our application requires GPU acceleration, the NVIDIA Container Toolkit ensures seamless integration.