This guide covers two types of Docker images for ME-Chain:
- Private Network Image - Pre-initialized single-node test network
- Release Image - Minimal production-ready binary image
A pre-compiled and pre-initialized single-node private network with test accounts. Perfect for:
- Local development
- Testing and CI/CD
- Quick prototyping
Build: make docker-private-net
Tag: me-hub/private-net:latest
A minimal runtime image containing only the compiled med binary. Perfect for:
- Production deployments
- Custom chain configurations
- Base image for other containers
Build: make docker-release
Tag: me-hub/release:latest
# 1. Build Docker image
make docker-private-net
# 2. Start private network
make docker-private-net-start
# 3. Test network functionality
make docker-private-net-test
# 4. Stop network
make docker-private-net-stop# Start
docker compose -f docker/docker-compose.yml up -d
# View logs
docker compose -f docker/docker-compose.yml logs -f
# Stop
docker compose -f docker/docker-compose.yml down# Start with persistent data
docker run -d \
-p 36657:36657 \
-p 1318:1318 \
-p 9545:9545 \
-p 8090:8090 \
-v mechain-data:/root/.mechain \
--name mechain-private-net \
me-hub/private-net:latest
# View logs
docker logs -f mechain-private-net
# Stop and clean up
docker stop mechain-private-net
docker rm mechain-private-netAfter successful startup, you can access the network through the following endpoints:
| Service | Port | URL |
|---|---|---|
| RPC | 36657 | http://localhost:36657 |
| REST API | 1318 | http://localhost:1318 |
| JSON-RPC | 9545 | http://localhost:9545 |
| JSON-RPC WebSocket | 9546 | ws://localhost:9546 |
| gRPC | 8090 | localhost:8090 |
| gRPC-web | 8091 | localhost:8091 |
| P2P | 36656 | - |
The private network includes the following pre-configured test accounts (using test keyring):
# Mnemonic
curtain hat remain song receive tower stereo hope frog cheap brown plate
raccoon post reflect wool sail salmon game salon group glimpse adult shift
# View address
docker exec mechain-private-net med keys show global_dao -a --keyring-backend test
# Expected address
me139mq752delxv78jvtmwxhasyrycufsvr0mue6u
# Check balance
docker exec mechain-private-net med query bank balances \
me139mq752delxv78jvtmwxhasyrycufsvr0mue6uInitial Balance: 1,000,000,000,000,000,000,000,000 umec (1,000,000 MEC)
| Account Name | Purpose | Initial Balance |
|---|---|---|
| global_dao | Main account/DAO | 1,000,000 MEC |
| pools | AMM pool account | 1,000,000 MEC |
| user | Test user account | 1,000,000 MEC |
| sequencer | Sequencer account | 0.0001 MEC |
You can create additional genesis accounts at build time or runtime using environment variables. This is especially useful for CI/CD pipelines and automated testing.
π See GENESIS_ACCOUNTS.md for detailed documentation.
# Simple format: Create multiple accounts with specified amounts
make docker-private-net \
GENESIS_ACCOUNTS="alice:1000000000000000000000umec,bob:1000000000000000000000umec"
# JSON format: More control (can specify mnemonics)
make docker-private-net \
GENESIS_ACCOUNTS_JSON='[{"name":"alice","amount":"2000000000000000000000umec"}]'# Add accounts when starting the container
docker run -d \
-p 36657:36657 -p 1318:1318 -p 9545:9545 -p 8090:8090 \
-e GENESIS_ACCOUNTS="test1:1000000000000000000000umec,test2:500000000000000000000umec" \
--name mechain-private-net \
me-hub/private-net:latestEdit docker/docker-compose.yml:
services:
mechain-private-net:
environment:
- GENESIS_ACCOUNTS=alice:1000000000000000000000umec,bob:1000000000000000000000umec# List all accounts
docker exec mechain-private-net med keys list --keyring-backend test
# Check balance of custom account
docker exec mechain-private-net med keys show alice --keyring-backend test -a
docker exec mechain-private-net med query bank balances <alice_address>
# Or use the test script
chmod +x docker/scripts/test_genesis_accounts.sh
./docker/scripts/test_genesis_accounts.shCreate custom test networks automatically:
- name: Build test network with custom accounts
run: |
make docker-private-net \
GENESIS_ACCOUNTS="alice:10000000000000000000000umec,bob:5000000000000000000000umec"For complete documentation including:
- JSON format with mnemonic support
- Amount calculation reference
- GitHub Actions workflow examples
- Troubleshooting guide
π See GENESIS_ACCOUNTS.md
# 1. Check node status
curl http://localhost:36657/status
# 2. View Chain ID and block height
curl -s http://localhost:36657/status | jq '.result.node_info.network, .result.sync_info.latest_block_height'
# 3. Check REST API
curl http://localhost:1318/cosmos/base/tendermint/v1beta1/node_info
# 4. Check JSON-RPC
curl -X POST http://localhost:9545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
# 5. Run complete test suite
make docker-private-net-test# List all accounts
docker exec mechain-private-net med keys list --keyring-backend test
# Check specific account balance
docker exec mechain-private-net med query bank balances \
me139mq752delxv78jvtmwxhasyrycufsvr0mue6u
# View account details
docker exec mechain-private-net med keys show global_dao --keyring-backend test# Send tokens
docker exec mechain-private-net med tx bank send \
me139mq752delxv78jvtmwxhasyrycufsvr0mue6u \
<target_address> \
1000000umec \
--chain-id mechain_100-1 \
--keyring-backend test \
--yes
# Query transaction
docker exec mechain-private-net med query tx <TX_HASH># View validator list
docker exec mechain-private-net med query staking validators
# View validator details
docker exec mechain-private-net med query staking validator \
mevaloper139mq752delxv78jvtmwxhasyrycufsvr707ate# Query block height
docker exec mechain-private-net med status | jq .SyncInfo.latest_block_height
# Query specific block
docker exec mechain-private-net med query block <HEIGHT>
# View chain parameters
docker exec mechain-private-net med query staking params# Enter container shell
docker exec -it mechain-private-net sh
# View real-time logs
docker logs -f mechain-private-net
# View recent logs
docker logs --tail 100 mechain-private-net
# Check container status
docker ps | grep mechain-private-net
# Check container resource usage
docker stats mechain-private-net --no-streamCustomize chain configuration through environment variables:
| Variable | Default Value | Description |
|---|---|---|
CHAIN_ID |
mechain_100-1 | Chain ID |
MONIKER_NAME |
local | Node name |
KEY_NAME |
global_dao | Main account name |
TZ |
Asia/Shanghai | Timezone setting |
GENESIS_ACCOUNTS |
"" | Custom genesis accounts (simple format) |
GENESIS_ACCOUNTS_JSON |
"" | Custom genesis accounts (JSON format) |
Example:
docker run -d \
-e CHAIN_ID="mechain_100-1" \
-e MONIKER_NAME="my-node" \
-e KEY_NAME="global_dao" \
-e TZ="UTC" \
-p 36657:36657 \
-p 1318:1318 \
-p 9545:9545 \
-p 8090:8090 \
--name mechain-private-net \
me-hub/private-net:latestThe release image is a minimal runtime image without any chain initialization. It only contains the med binary and required libraries.
# Build with default tag (latest)
make docker-release
# Build with specific tag
make docker-release TAG=v1.0.0# Run from Docker image
docker run --rm me-hub/release:latest version
# Check detailed version
docker run --rm me-hub/release:latest version --long# Show all available commands
docker run --rm me-hub/release:latest --help
# Show help for specific command
docker run --rm me-hub/release:latest init --help# Create a volume for chain data
docker volume create mychain-data
# Initialize a new chain
docker run --rm \
-v mychain-data:/root/.mechain \
me-hub/release:latest \
init mynode --chain-id mychain_100-1
# Add keys
docker run --rm \
-v mychain-data:/root/.mechain \
me-hub/release:latest \
keys add mykey --keyring-backend test
# Run your custom chain
docker run -d \
-v mychain-data:/root/.mechain \
-p 36657:36657 -p 1318:1318 -p 9545:9545 \
--name mychain \
--entrypoint med \
me-hub/release:latest \
startCreate your own Dockerfile:
FROM me-hub/release:latest
# Copy your custom genesis file
COPY genesis.json /root/.mechain/config/genesis.json
# Copy your custom configuration
COPY config.toml /root/.mechain/config/config.toml
COPY app.toml /root/.mechain/config/app.toml
# Set custom entrypoint
COPY start-chain.sh /scripts/start-chain.sh
RUN chmod +x /scripts/start-chain.sh
ENTRYPOINT ["/scripts/start-chain.sh"]# Enter container with shell
docker run -it --rm \
-v mychain-data:/root/.mechain \
--entrypoint sh \
me-hub/release:latest
# Now you can run any med commands
# med init mynode --chain-id test
# med keys add mykey
# med startThe release image is automatically built and pushed when a tag is pushed:
# .github/workflows/build-push-release.yml
name: Build and Push Release Docker Image
on:
push:
tags:
- "v*"This will:
- Build the release Docker image
- Tag it with the git tag (e.g.,
v1.0.0) - Push to Harbor registry
- Verify by running
med version
# Pull specific version
docker pull your-registry/openmetaearth/me_hub:v1.0.0
# Pull latest
docker pull your-registry/openmetaearth/me_hub:latest
# Check version
docker run --rm your-registry/openmetaearth/me_hub:v1.0.0 version| Feature | Release Image | Private Network Image |
|---|---|---|
| Size | ~200MB | ~423MB |
| Includes | Binary only | Binary + initialized chain |
| Pre-configured | No | Yes (test accounts) |
| Use Case | Production/Custom | Development/Testing |
| Startup | Requires init | Ready to run |
| Entrypoint | med |
Startup script |
| Default CMD | version |
Starts chain |
# Start with specified volume
docker run -d \
-v mechain-data:/root/.mechain \
-p 36657:36657 -p 1318:1318 -p 9545:9545 -p 8090:8090 \
--name mechain-private-net \
me-hub/private-net:latest
# View volume
docker volume ls | grep mechain
# Inspect volume contents
docker volume inspect mechain-data# Using Makefile
make docker-private-net-stop
docker volume rm docker_mechain-data
# Or using Docker Compose
docker compose -f docker/docker-compose.yml down -v
# Or using Docker commands
docker stop mechain-private-net
docker rm mechain-private-net
docker volume rm mechain-data
# Restart
make docker-private-net-start- CPU: 2+ cores
- Memory: Minimum 2GB, Recommended 4GB
- Disk: At least 1GB available space
- Network: Ports 36656-36657, 1318, 8090-8091, 9545-9546 available
- Image Size: ~423MB
- Runtime Memory: ~200MB
- CPU Usage: < 5% (idle)
- Startup Time: < 10 seconds
- Block Time: ~5 seconds/block
Docker container has built-in health check functionality:
# View health status
docker inspect mechain-private-net --format '{{.State.Health.Status}}'
# View health check logs
docker inspect mechain-private-net --format '{{json .State.Health}}' | jqHealth check configuration:
- Command:
med status - Interval: 30 seconds
- Timeout: 10 seconds
- Retries: 5 times
- Start Period: 60 seconds
# Check logs
docker logs mechain-private-net
# Check port usage
netstat -tuln | grep -E "36657|1318|9545|8090"
# Check disk space
df -h
docker system dfUse custom port mapping:
docker run -d \
-p 26657:36657 \
-p 2318:1318 \
-p 8545:9545 \
-p 9090:8090 \
--name mechain-private-net \
me-hub/private-net:latest# Check validator status
docker exec mechain-private-net med query staking validators
# Check node status
docker exec mechain-private-net med status
# View detailed logs
docker logs -f mechain-private-net | grep -E "ERROR|WARN"# Check configuration file
docker exec mechain-private-net cat /root/.mechain/config/app.toml | grep -A 5 "\[api\]"
# Check port mapping
docker port mechain-private-net
# Test internal container connection
docker exec mechain-private-net curl http://localhost:1318/cosmos/base/tendermint/v1beta1/node_info- Genesis Accounts Configuration - Detailed guide for creating custom accounts
- Quick Start Guide
- ME-Chain Main Documentation
- Build Release Workflow
- Build Private Network Workflow
docker/
βββ Dockerfile # Private network image definition
βββ Dockerfile.release # Release image definition (minimal)
βββ docker-compose.yml # Docker Compose configuration
βββ README.md # This document
βββ QUICKSTART.md # Quick start guide
βββ GENESIS_ACCOUNTS.md # Genesis accounts configuration guide
βββ scripts/
βββ setup_local_docker.sh # Chain initialization script
βββ start_private_net.sh # Container startup script
βββ test_private_net.sh # Automated test script
βββ test_genesis_accounts.sh # Genesis accounts verification script
.github/workflows/
βββ build-push-private-net.yml # CI/CD for private network image
βββ build-push-release.yml # CI/CD for release image
# 1. Start private network
make docker-private-net-start
# 2. Wait for initialization (about 10 seconds)
sleep 10
# 3. Run tests
make docker-private-net-test
# 4. Clean up after development
make docker-private-net-stop#!/bin/bash
# Use in CI pipeline
# Start test network
make docker-private-net-start
# Wait for chain to start
sleep 15
# Run integration tests
./run_integration_tests.sh
# Clean up
make docker-private-net-stop
docker volume rm docker_mechain-data- Use data persistence to avoid repeated initialization
- Regularly clean logs to avoid disk usage
- Use
docker statsto monitor resource usage - Keep test account private keys for development
β οΈ Production Use Prohibited: This configuration is for development and testing onlyβ οΈ Private Key Security: Pre-configured mnemonic is public, never use in productionβ οΈ Network Exposure: Do not expose ports to the public internetβ οΈ Keyring Backend: Usetestbackend for development only, usefileorosin production
Having issues?
- Check the Troubleshooting section
- Run
make docker-private-net-testto diagnose problems - View container logs:
docker logs mechain-private-net - Submit an issue to the project repository
- β Initial release
- β One-click private network startup
- β Built-in complete test suite
- β Data persistence support
- β Health check functionality
- β Release image for production deployments
- β GitHub Actions CI/CD workflows
Last Updated: 2024-11-12
Maintainer: ME-Chain Team