Sign inSign up

h4shelldocker/docker-environment

By h4shelldocker

•Updated 5 months ago

Image
0

1.9K

h4shelldocker/docker-environment repository overview

⁠Docker Development Environment

A comprehensive Docker-based development environment with SSH access, code-server IDE, Docker-in-Docker capabilities, and remote tunnel support via Cloudflare.

⁠Features

  • Ubuntu-based container with Docker-in-Docker (DinD) support
  • Code-server - VS Code in your browser
  • SSH server with key-based authentication
  • Lazydocker - Terminal UI for Docker management
  • Cloudflared - Secure tunneling for remote access
  • Git pre-configured with user settings
  • Sudo access for the development user

⁠Quick Start

⁠Prerequisites
  • Docker installed on your host system
  • Docker Compose (optional, for easier management)
⁠Basic Usage
  1. Build the image:

    docker build -t dev-environment .
    
  2. Run the container:

    docker run -d \
      --name dev-env \
      --privileged \
      -p 2222:22 \
      -p 8080:8080 \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -v $(pwd)/workspace:/home/user/workspace \
      dev-environment
    
  3. Access your environment:

    • SSH: ssh -p 2222 user@localhost (password: password)
    • Code-server: Open http://localhost:8080 in your browser
    • Lazydocker: Run lazydocker inside the container

Create a docker-compose.yml file:

services:
  docker-environment:
    image: h4shelldocker/docker-environment:latest
    privileged: true
    entrypoint: /usr/bin/entrypoint.sh
    container_name: docker-environment
    hostname: "docker-environment"
    restart: always
    ports:
      - "2222:22"
      - "2223:20223"
    volumes:
      - "home:/home"
      - "run:/var/run/"
    environment:
      - ENV_USER=user
      - ENV_PASS=password
      - GIT_NAME=Lorenzo Fornara
      - [email protected]

volumes:
  home:
    driver: local
  run:
    driver: local

Run with:

docker-compose up -d
⁠Docker Compose behind a NAT (Cloudflare Version)
services:
  docker-environment:
    image: h4shelldocker/docker-environment:latest
    privileged: true
    entrypoint: /usr/bin/entrypoint.sh
    container_name: docker-environment
    hostname: "docker-environment"
    restart: always
    ports:
      - "2222:22"
      - "2223:20223"
    volumes:
      - "home:/home"
      - "run:/var/run/"
    environment:
      - ENV_USER=user
      - ENV_PASS=password
      - GIT_NAME=Lorenzo Fornara
      - [email protected]
  
#  wetty-env:
#    image: wettyoss/wetty
#    container_name: wetty-env
#    restart: always
#    ports:
#      - "2220:20200"
#    entrypoint: node /usr/src/app/build/main.js -p 20200 --ssh-host docker-environment --ssh-user user
#    environment:
#      - SSH_HOST=docker-environment
#      - SSH_PORT=22
#      - BASE=/
  
  cloudflare-env:
    image: cloudflare/cloudflared:latest
    restart: always
    container_name: cloudflare-env
    command: tunnel --url docker-environment:20223

volumes:
  home:
    driver: local
  run:
    driver: local

⁠Configuration

⁠Build Arguments

You can customize the environment during build:

docker build \
  --build-arg ENV_USER=myuser \
  --build-arg ENV_PASS=mypassword \
  --build-arg GIT_NAME="Your Name" \
  --build-arg GIT_EMAIL="[email protected]" \
  -t docker-environment .

Available build arguments:

  • ENV_USER: Username for the development user (default: user)
  • ENV_PASS: Password for the development user (default: password)
  • DIR: Installation directory for binaries (default: /usr/bin)
  • GIT_NAME: Git username (default: h4shell)
  • GIT_EMAIL: Git email (default: [email protected])
⁠SSH Access

The container generates SSH keys automatically. To use key-based authentication:

  1. Copy the private key from the container:

    docker cp dev-env:/home/user/.ssh/id_rsa_env ~/.ssh/dev-env-key
    chmod 600 ~/.ssh/dev-env-key
    
  2. Connect using the key:

    ssh -i ~/.ssh/dev-env-key -p 2222 user@localhost
    

⁠File Structure

The container expects these files in your build context:

.
├── Dockerfile
├── .bashrc          # Custom bash configuration
├── tunnel           # Cloudflare tunnel configuration script
└── entrypoint.sh    # Container startup script

⁠Ports

  • 22: SSH server
  • 20223: Custom application port

⁠Security Notes

⚠️ Important Security Considerations:

  • This container runs in privileged mode for Docker-in-Docker functionality
  • Default credentials are user:password - change them in production
  • SSH keys are auto-generated - secure them properly
  • The container has sudo access - use responsibly

⁠Troubleshooting

⁠Docker-in-Docker Issues

If Docker commands fail inside the container:

# Check Docker daemon status
docker exec -it dev-env service docker status

# Restart Docker daemon
docker exec -it dev-env service docker restart
⁠SSH Connection Issues
# Check SSH service status
docker exec -it dev-env service ssh status

# View SSH logs
docker exec -it dev-env tail -f /var/log/auth.log

⁠Development Workflow

  1. Start the environment:

    docker-compose up -d
    
  2. Access via SSH for terminal work:

    ssh -p 2222 user@localhost
    
  3. Use code-server for IDE features:

    • Open http://localhost:2223
    • Install extensions as needed
    • Configure workspace settings
  4. Manage Docker containers:

    # Inside the container
    lazydocker
    # or
    docker ps
    

⁠Contributing

Feel free to submit issues and pull requests to improve this development environment.

⁠License

This project is open source. Please check the license file for details.

Tag summary

Content type

Image

Digest

sha256:3c42b066d…

Size

785.1 MB

Last updated

5 months ago

docker pull h4shelldocker/docker-environment