Skip to main content
rcon-cli is a command-line tool bundled with the itzg/minecraft-server image that provides CLI access to RCON (Remote Console) endpoints. It enables you to send commands to the Minecraft server without needing to attach to the console.
Version: 1.7.3
Repository: itzg/rcon-cli

Overview

RCON (Remote Console) is enabled by default in the itzg/minecraft-server image, allowing you to execute commands remotely. The rcon-cli tool provides a simple interface for interacting with the server console.

Usage

Interactive Mode

To access the Minecraft server console interactively:
docker exec -i mc rcon-cli
The -i flag is required for interactive use of rcon-cli.
Once in interactive mode, you can type any Minecraft server command directly:
> list
There are 0 of a max of 20 players online:
> say Hello, players!
[Server] Hello, players!
> stop
Stopping the server...
Exit interactive mode with Ctrl+D or by typing quit.

One-Shot Commands

To execute a single command without entering interactive mode, pass the command as arguments:
docker exec mc rcon-cli stop
docker exec mc rcon-cli say Server restart in 5 minutes
docker exec mc rcon-cli list
The -i flag is not needed for one-shot commands.

Common Commands

Server Management

# Stop the server gracefully
docker exec mc rcon-cli stop

# Save the world
docker exec mc rcon-cli save-all

# List online players
docker exec mc rcon-cli list

# Broadcast a message
docker exec mc rcon-cli say Welcome to the server!

Player Management

# Give operator permissions
docker exec mc rcon-cli op playername

# Remove operator permissions
docker exec mc rcon-cli deop playername

# Kick a player
docker exec mc rcon-cli kick playername Reason for kick

# Ban a player
docker exec mc rcon-cli ban playername

# Teleport a player
docker exec mc rcon-cli tp playername x y z

World Management

# Set the time
docker exec mc rcon-cli time set day
docker exec mc rcon-cli time set night

# Set the weather
docker exec mc rcon-cli weather clear
docker exec mc rcon-cli weather rain

# Set game rule
docker exec mc rcon-cli gamerule doDaylightCycle false

Configuration

rcon-cli automatically connects to the RCON port configured in your server. By default, it uses:
  • Host: localhost
  • Port: 25575 (default RCON port)
  • Password: Value from RCON_PASSWORD environment variable

Environment Variables

You can customize RCON configuration through these environment variables:
  • RCON_PORT - Change the RCON port (default: 25575)
  • RCON_PASSWORD - Set the RCON password (randomly generated by default)
  • ENABLE_RCON - Enable/disable RCON (default: true)

When RCON is Disabled

If you disable RCON with ENABLE_RCON=false, you can still send commands using the mc-send-to-console script:
docker exec --user 1000 mc mc-send-to-console op playername
Disabling RCON removes some features, including:
  • Interactive console support
  • Colorized log output
  • Auto-completion
Set the environment variable CREATE_CONSOLE_IN_PIPE=true to enable console pipe functionality.

Advanced Usage

With Docker Compose

In a Docker Compose setup:
# Interactive mode
docker compose exec -i minecraft rcon-cli

# One-shot command
docker compose exec minecraft rcon-cli list

Scripting

You can use rcon-cli in scripts for automation:
#!/bin/bash

# Backup script
docker exec mc rcon-cli save-off
docker exec mc rcon-cli save-all flush
# ... perform backup ...
docker exec mc rcon-cli save-on

Multiple Commands

Execute multiple commands in sequence:
docker exec mc rcon-cli << EOF
save-all
say Backing up world...
EOF

Troubleshooting

Authentication Failed

If you get authentication errors:
  1. Check that RCON is enabled (ENABLE_RCON=true)
  2. Verify the RCON password is correct
  3. Check the RCON port is correct (default 25575)

Connection Refused

If rcon-cli cannot connect:
  1. Ensure the server is fully started
  2. Check that RCON is enabled in server configuration
  3. Verify the RCON port is not blocked

Command Not Found

If you get “command not found”:
  • The rcon-cli tool is only available inside the container
  • Always use docker exec to run it
See also:

Build docs developers (and LLMs) love