<commit_before># Dockercraft
A simple Minecraft docker client, to visualize and run containers.

[![Dockercraft video](http://img.youtube.com/vi/eZDlJgJf55o/0.jpg)](http://www.youtube.com/watch?v=eZDlJgJf55o)

### Build the image:

```
docker build -t mcclient .
```

### Run the container:

```
docker run -t -i --rm -p 25565:25565 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/local/bin/docker:/usr/local/bin/docker \
--name mcclient mcclient
```

Mounting `/var/run/docker.sock` inside the container is necessary to send requests to the Docker remote API.

Mounting `/usr/local/bin/docker` inside the container is necessary to bind Minecraft commands to Docker CLI commands.


### How it works

The game itself remains unmodified. All operations are done server side. 

The Minecraft server we use is [http://cuberite.org](http://cuberite.org). A custom Minecraft compatible game server written in C++. [github repo](https://github.com/cuberite/cuberite)

This server accepts plugins, scripts written in LUA. So we did one for Docker. (world/Plugins/Docker)

Unfortunately, there's no nice API to communicate with these plugins. But there's a webadmin, and plugins can be responsible for "webtabs". 

```lua
Plugin:AddWebTab("Docker",HandleRequest_Docker)
```
Basically it means the plungin can catch POST requests sent to `http://127.0.0.1:8080/webadmin/Docker/Docker`. 

#### Goproxy

Events from the Docker remote API are transmitted to the LUA plugin by a small daemon (written in Go). (go/src/goproxy)

```golang
func MCServerRequest(data url.Values, client *http.Client) {
	req, _ := http.NewRequest("POST", "http://127.0.0.1:8080/webadmin/Docker/Docker", strings.NewReader(data.Encode()))
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.SetBasicAuth("admin", "<PASSWORD>")
	client.Do(req)<commit_msg>README: Updated command to run container<commit_after># Dockercraft
A simple Minecraft docker client, to visualize and run containers.

[![Dockercraft video](http://img.youtube.com/vi/eZDlJgJf55o/0.jpg)](http://www.youtube.com/watch?v=eZDlJgJf55o)

### Build the image:

```
docker build -t mcclient .
```

### Run the container:

```
docker run -t -i -d -p 25565:25565 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `machine ssh $(machine active) which docker`:/usr/local/bin/docker \
--name mcclient mcclient
```

Mounting `/var/run/docker.sock` inside the container is necessary to send requests to the Docker remote API.

Mounting `/usr/local/bin/docker` inside the container is necessary to bind Minecraft commands to Docker CLI commands. The binary may not always be stored at the same place depending on the environment, if you're using **docker-machine**, this command should return the right path: `machine ssh $(machine active) which docker`


### How it works

The game itself remains unmodified. All operations are done server side. 

The Minecraft server we use is [http://cuberite.org](http://cuberite.org). A custom Minecraft compatible game server written in C++. [github repo](https://github.com/cuberite/cuberite)

This server accepts plugins, scripts written in LUA. So we did one for Docker. (world/Plugins/Docker)

Unfortunately, there's no nice API to communicate with these plugins. But there's a webadmin, and plugins can be responsible for "webtabs". 

```lua
Plugin:AddWebTab("Docker",HandleRequest_Docker)
```
Basically it means the plungin can catch POST requests sent to `http://127.0.0.1:8080/webadmin/Docker/Docker`. 

#### Goproxy

Events from the Docker remote API are transmitted to the LUA plugin by a small daemon (written in Go). (go/src/goproxy)

```golang
func MCServerRequest(data url.Values, client *http.Client) {
	req, _ := http.NewRequest("POST", "http://127.0.0.1:8080/webadmin/Docker/Docker", strings.NewReader(data.Encode()))
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.SetBasicAuth("admin", "admin")
	client.Do(req)
{'fraction_non_alphanumeric': 0.12801013941698353, 'fraction_numerical': 0.017743979721166033, 'mean_word_length': 4.581329561527581, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2416942', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1231, 'n_words': 413}