diff --git a/DockerfileUbuntu b/DockerfileUbuntu
new file mode 100644
index 0000000..45c6038
--- /dev/null
+++ b/DockerfileUbuntu
@@ -0,0 +1,11 @@
+FROM ubuntu:latest
+
+RUN apt update && apt install libreadline-dev libcurl4-openssl-dev libssl-dev libncurses5-dev libncursesw5-dev libsqlite3-dev libreadline6-dev zlib1g-dev libbz2-dev libffi-dev liblzma-dev python3 python3-pip python3-venv libjson-c-dev vim htop git curl wget -y
+
+RUN wget https://retoor.molodetz.nl/api/packages/retoor/generic/r/1.0.0/r
+
+RUN chmod +x r
+
+RUN cp r /usr/local/bin
+
+CMD ["r"]
diff --git a/Makefile b/Makefile
index c9a7a28..878e699 100644
--- a/Makefile
+++ b/Makefile
@@ -11,12 +11,15 @@ python:
 dump:
 	@$(PYTHON) -m snek.dump
 
+build:
+
+
 run:
 	$(GUNICORN) -w $(GUNICORN_WORKERS) -k aiohttp.worker.GunicornWebWorker snek.gunicorn:app --bind 0.0.0.0:$(PORT) --reload
 	
 install:
 	python3.12 -m venv .venv 
 	$(PIP) install -e .
-
+	docker build -f DockerfileUbuntu -t snek_ubuntu .
 
 
diff --git a/src/snek/system/terminal.py b/src/snek/system/terminal.py
index 6a91040..80dda17 100644
--- a/src/snek/system/terminal.py
+++ b/src/snek/system/terminal.py
@@ -32,7 +32,7 @@ class TerminalSession:
 
     async def read_output(self, ws):
         self.sockets.append(ws)
-        if len(self.sockets) > 1 and self.buffer:
+        if len(self.sockets) > 1 and self.history:
             start = 0
             try:
                 start = self.history.index(b'\n')
diff --git a/src/snek/view/terminal.py b/src/snek/view/terminal.py
index fac680c..6596f2c 100644
--- a/src/snek/view/terminal.py
+++ b/src/snek/view/terminal.py
@@ -30,7 +30,10 @@ class TerminalSocketView(BaseView):
         user = await self.services.user.get(uid=self.session.get("uid"))
         root = await self.prepare_drive()
         
-        command = f"docker run -v ./{root}/:/root --rm -it --memory 512M --cpus=0.5 -w /root ubuntu:latest /bin/bash"
+
+        
+
+        command = f"docker run -v ./{root}/:/root -it --memory 512M --cpus=0.5 -w /root snek_ubuntu /bin/bash"
 
         session = self.user_sessions.get(user["uid"])
         if not session:
diff --git a/terminal/.bashrc b/terminal/.bashrc
index e4022a9..ee7d93f 100644
--- a/terminal/.bashrc
+++ b/terminal/.bashrc
@@ -92,11 +92,6 @@ if [ -f ~/.bash_aliases ]; then
 fi
 
 
-cp ~/r /usr/local/bin 
-
-chmod +x /usr/local/bin/r
-
-apt update && apt install libreadline-dev libcurl4-openssl-dev libssl-dev libncurses5-dev libncursesw5-dev libsqlite3-dev libreadline6-dev zlib1g-dev libbz2-dev libffi-dev liblzma-dev python3 python3-pip python3-venv libjson-c-dev vim htop git -y
 
 echo "R is installed. Type r to run it."
 
diff --git a/terminal/r b/terminal/r
deleted file mode 100755
index 2cc65df..0000000
Binary files a/terminal/r and /dev/null differ