2023-05-28 21:14:57 +00:00
---
title: Sending commands
---
2023-05-28 17:55:47 +00:00
[RCON ](http://wiki.vg/RCON ) is enabled by default, so you can `exec` into the container to
access the Minecraft server console:
```
docker exec -i mc rcon-cli
```
Note: The `-i` is required for interactive use of rcon-cli.
To run a simple, one-shot command, such as stopping a Minecraft server, pass the command as arguments to `rcon-cli` , such as:
```
docker exec mc rcon-cli stop
```
_The `-i` is not needed in this case._
2024-02-10 19:24:06 +00:00
## When RCON is disabled
If rcon is disabled you can send commands by passing them as arguments to the packaged `mc-send-to-console` script after setting the env var `CREATE_CONSOLE_IN_PIPE` to "true". For example, a player can be op'ed in the container `mc` with:
2023-05-28 17:55:47 +00:00
```shell
docker exec mc mc-send-to-console op player
| |
+- container name +- Minecraft commands start here
```
2024-02-10 19:24:06 +00:00
## Enabling interactive console
In order to attach and interact with the Minecraft server make sure to enable TTY and keep stdin open.
!!! example
With `docker run` use the `-it` arguments:
2023-05-28 17:55:47 +00:00
2024-02-10 19:24:06 +00:00
```shell
2023-05-28 17:55:47 +00:00
docker run -d -it -p 25565:25565 --name mc itzg/minecraft-server
2024-02-10 19:24:06 +00:00
```
or with a compose file:
```yaml
services:
minecraft:
stdin_open: true
tty: true
```
2023-05-28 17:55:47 +00:00
With that you can attach and interact at any time using
docker attach mc
and then Control-p Control-q to **detach** .
2024-02-10 19:24:06 +00:00
!!! info "RCON is required for fully interactive, color console"
2023-05-28 17:55:47 +00:00
2024-02-10 19:24:06 +00:00
RCON must be enabled, which is the default, in order to use a fully interactive console with auto-completion and colorized log output.