Skip to content

Tutorials-Dojo/docker-playclouds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Docker Playclouds

Docker Playclouds gives you the experience of having a free Alpine Linux Virtual Machine in the cloud where you can build and run Docker containers and even create clusters with Docker features like Swarm Mode.

Under the hood DIND or Docker-in-Docker is used to give the effect of multiple VMs/PCs.

Original project: Play With Docker


πŸš€ Quick Deploy to AWS EC2

Deploy Docker Playclouds to AWS EC2 with automated setup:

Automated Deployment (Recommended)

  1. Launch EC2 Instance:

    • AMI: Amazon Linux 2023 or Ubuntu 22.04
    • Instance Type: t3.medium or larger (minimum 2 vCPU, 4GB RAM)
    • Storage: 30GB gp3
  2. Configure Security Group:

    • Port 22 (SSH): 0.0.0.0/0
    • Port 80 (HTTP): 0.0.0.0/0
    • Port 443 (HTTPS): 0.0.0.0/0
  3. Add User Data:

    • Copy the contents of ec2-user-data-updated.sh
    • IMPORTANT: Update the DOMAIN variable with your domain
    • Paste into the User Data field during instance launch
  4. Configure DNS:

    • Point your domain's A record to the EC2 instance public IP
    • Wait for DNS propagation (5-30 minutes)
  5. Access:

    • Navigate to https://your-domain.com
    • Click "Launch" to create a Docker playground session

Manual Deployment

For step-by-step manual deployment instructions, see:

πŸ“– EC2 Deployment Guide - Complete deployment documentation


πŸ“ Repository Structure

docker-playclouds/
β”œβ”€β”€ ec2-user-data-updated.sh           # EC2 automated deployment script
β”œβ”€β”€ EC2-DEPLOYMENT-GUIDE-FINAL.md      # Complete EC2 deployment guide
β”œβ”€β”€ docker-compose.yml                  # Container orchestration config
β”œβ”€β”€ Dockerfile.dind                     # Docker-in-Docker image
β”œβ”€β”€ haproxy/
β”‚   └── haproxy.cfg                    # Load balancer configuration
β”œβ”€β”€ handlers/                           # Application handlers
β”œβ”€β”€ router/                             # L2 network router
β”œβ”€β”€ dockerfiles/                        # System container definitions
└── README.md                          # This file

πŸ”§ Key Configuration Files

docker-compose.yml

Defines three main services:

  • haproxy: Load balancer and reverse proxy (ports 80, 443)
  • pwd: Main application server (port 3000)
  • l2: Network routing layer (ports 8022, 8053)

Important: The pwd service must include -playground-domain YOUR_DOMAIN parameter.

haproxy/haproxy.cfg

  • SSL/TLS termination
  • HTTP to HTTPS redirect
  • Backend routing to pwd and l2 services

ec2-user-data-updated.sh

Automated deployment script that:

  • Installs Docker and Docker Compose
  • Clones repository
  • Applies critical configuration fixes
  • Builds DinD image
  • Deploys containers
  • Verifies deployment

πŸ›  Local Development

Requirements

Setup

# Clone this repo locally
git clone https://github.com/Tutorials-Dojo/docker-playclouds.git
cd docker-playclouds

# Verify the Docker daemon is running
docker run hello-world

# Load the IPVS kernel module
sudo modprobe xt_ipvs

# Ensure Docker is in swarm mode
docker swarm init

# Build the DinD image
docker build -t local/dind-motd:latest -f Dockerfile.dind .

# Start services
docker-compose up -d

Now navigate to http://localhost:3000 and click "Launch" to create a new session.

Port Forwarding for Development

For port forwarding to work correctly in development, configure *.localhost to resolve to 127.0.0.1:

  1. Set up a dnsmasq server with this configuration:

    address=/localhost/127.0.0.1
    
  2. Configure your system DNS to use the dnsmasq server


πŸ“ Deployment Notes

GCP vs EC2 Differences

Aspect GCP (Container-Optimized OS) AWS EC2 (Amazon Linux/Ubuntu)
Docker Pre-installed Manual installation required
Deployment Direct docker run docker-compose
Configuration CLI parameters docker-compose.yml + user data

Critical Configuration Parameters

When deploying to EC2, ensure:

  1. βœ… -playground-domain YOUR_DOMAIN is set in both pwd command paths (binary and go run)
  2. βœ… HAProxy exposes both ports: 80:8080 and 443:8443
  3. βœ… L2 container does not expose port 443:443 (conflicts with HAProxy)
  4. βœ… Security Group allows inbound traffic on ports 22, 80, 443
  5. βœ… DNS A record points to EC2 public IP

πŸ” Troubleshooting

404 Not Found

Cause: Playground domain not configured correctly

Fix:

docker exec pwd cat /pwd/sessions | grep domain
# Should show: "domain":"your-domain.com"
# If not, check docker-compose.yml has -playground-domain parameter

503 Service Unavailable

Cause: Containers still initializing

Fix: Wait 1-2 minutes for Go compilation and container startup

Connection Refused

Cause: Security group not configured

Fix: Ensure AWS Security Group allows ports 80, 443, 22 from 0.0.0.0/0

SSL Certificate Warning

Cause: Using self-signed certificate or domain mismatch

Fix:

  • Production: Use Let's Encrypt certificate
  • Testing: Click "Proceed" in browser

πŸ“š Additional Resources


🀝 Contributing

Contributions are welcome! Please ensure:

  • Code follows existing patterns
  • Documentation is updated
  • Deployment scripts are tested

πŸ“„ License

This project maintains the same license as the original Play With Docker project.


πŸ’‘ FAQ

How can I connect to a published port from the outside world?

Use the URL pattern: http://ip<hyphen-ip>-<session_id>-<port>.direct.your-domain.com

Example: http://ip10-0-1-4-8080.direct.dockerlabs.tutorialsdojo.com

Can I change the ports PWD runs on?

No, it needs to run on ports 80/443 for DNS resolution to work correctly. The domain-based routing is essential for the multi-session functionality.

How long do sessions last?

Sessions last for 15 minutes by default (900 seconds). This can be configured in the playground settings.


Last Updated: October 2025 Tested On: Amazon Linux 2023, Ubuntu 22.04

About

A Docker Playground.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published