This repository contains scripts to set up a Docker learning environment using Multipass virtual machines.
This project provides an automated way to create Ubuntu virtual machines with Docker pre-installed, perfect for learning Docker concepts in an isolated environment.
- Multipass installed on your system
- Linux operating system (tested on Ubuntu)
Main script that creates and configures a new Multipass VM with Docker installed.
Usage:
./init_instance.sh <instance_name>What it does:
- Launches a new Ubuntu 22.04 (Jammy) VM with:
- 1GB RAM
- 4GB disk space
- 2 CPU cores
- Transfers the Docker installation script to the VM
- Executes the Docker installation script
Docker installation script that sets up Docker CE on Ubuntu.
Features:
- Updates system packages
- Installs Docker CE, CLI, and related components
- Adds user to docker group for non-root access
- Enables Docker daemon for automatic startup
- Installs Docker Compose plugin
-
Make the scripts executable:
chmod +x init_instance.sh install-docker.sh
-
Create a new Docker learning environment:
./init_instance.sh my-docker-vm
-
Connect to your new VM:
multipass shell my-docker-vm
-
Verify Docker installation:
docker --version docker compose version
-
Test Docker with a simple container:
docker run hello-world
The created virtual machine has the following specifications:
- OS: Ubuntu 22.04 LTS (Jammy)
- Memory: 1GB RAM
- Storage: 4GB disk
- CPU: 2 cores
- Docker CE (Community Edition)
- Docker CLI
- containerd.io
- Docker Buildx plugin
- Docker Compose plugin
# Stop the VM
multipass stop my-docker-vm
# Start the VM
multipass start my-docker-vm
# Restart the VM
multipass restart my-docker-vm# List all VMs
multipass list
# Get detailed info about a specific VM
multipass info my-docker-vm# Stop and delete the VM
multipass delete my-docker-vm
multipass purgeOnce your environment is set up, you can start learning Docker with these basic commands:
# Pull an image
docker pull nginx
# Run a container
docker run -d -p 8080:80 nginx
# List running containers
docker ps
# Stop a container
docker stop <container_id>
# Remove a container
docker rm <container_id>If you encounter permission issues with Docker commands, log out and log back in, or run:
newgrp dockerIf the VM fails to start, check your system resources and ensure Multipass is properly installed:
multipass version