Get Rewarded! We will reward you with up to €50 credit on your account for every tutorial that you write and we publish!

Run Docker containers on a Managed Server with udocker

profile picture
Author
Alexander Knerlein
Published
2022-05-10
Time to read
3 minutes reading time

Introduction

In this tutorial we will learn how to run Docker containers on a Managed Server. Udocker is a non-root implementation of Docker, based on PRoot and some other selectable runtimes. PRoot is a non-root implementation of chroot. Udocker in PRoot mode is no real container based virtualization, because it extracts the filesystem of the container and PRoots into.

Prerequisites

Step 1 Option 1 - Install udocker with pip

Install udocker with the Python package manager pip.

pip3 install --break-system-packages udocker
export PROOT_TMP_DIR="/usr/home/holu/.tmp"
echo "export PROOT_TMP_DIR=\"/usr/home/holu/.tmp\"" >> .bashrc
udocker install

Step 1 Option 2 - Install udocker (alternative to pip)

Download and install udocker.

  • Always check on github for newer stable versions
cd
wget https://github.com/indigo-dc/udocker/releases/download/1.3.17/udocker-1.3.17.tar.gz
tar xzvf udocker-1.3.17.tar.gz
export PATH="/usr/home/holu/udocker-1.3.17/udocker:$PATH"
export PROOT_TMP_DIR="/usr/home/holu/.tmp"
echo "PATH=\"/usr/home/holu/udocker-1.3.17/udocker:\$PATH\"" >> .bashrc
echo "export PROOT_TMP_DIR=\"/usr/home/holu/.tmp\"" >> .bashrc
sed '1s/#!\/usr\/bin\/env python/#!\/usr\/bin\/env python3/' -i udocker-1.3.17/udocker/maincmd.py
udocker install

Step 2 - Pull an image and run a container

Sometimes you have to do a little bit of debugging first. Below you can see a few examples how to run different services.

Example with nginx:

udocker pull nginx
udocker create --name=mynginx nginx
sed "s/listen *80;/listen 8080;\n    listen [::]:8080;/" -i /usr/home/holu/.udocker/containers/mynginx/ROOT/etc/nginx/conf.d/default.conf
rm /usr/home/holu/.udocker/containers/mynginx/ROOT/var/log/nginx/{access,error}.log
touch /usr/home/holu/.udocker/containers/mynginx/ROOT/var/log/nginx/{access,error}.log
echo -e '#!/bin/sh\ntail -F /var/log/nginx/access.log &\ntail -F /var/log/nginx/error.log >&2 &' > /usr/home/holu/.udocker/containers/mynginx/ROOT/docker-entrypoint.d/logtail.sh
chmod 755 /usr/home/holu/.udocker/containers/mynginx/ROOT/docker-entrypoint.d/logtail.sh
nohup udocker run mynginx &

Example with Memcached:

udocker pull memcached
udocker create --name=mymemcached memcached
mkdir /usr/home/holu/.udocker/containers/mymemcached/ROOT/home/memcache
nohup udocker run mymemcached & 

Good to know:

  • You can only use ports > 1024 for services
  • If a container image uses a port < 1024, please change the config
  • You can access the containers filesystem from your host under /usr/home/holu/.udocker/containers/<containername>/ROOT
  • If your container gets killed, please ask the support for proot-x86_64-4_ / python3 process releases
  • Other processes inside of the container maybe also need a process release

Conclusion

Now you know a way to run Docker containers on a Managed Server. Please also understand that some containers can be inexecutable or faulty, because it's no real Docker software and you are still in a restricted environment. It can also be less secure than the real Docker. Please read the user manual of the developer for further information.

License: MIT
Want to contribute?

Get Rewarded: Get up to €50 in credit! Be a part of the community and contribute. Do it for the money. Do it for the bragging rights. And do it to teach others!

Report Issue

Discover our

Managed Servers

Get €20/$20 free credit!

Valid until: 31 December 2026 Valid for: 3 months and only for new customers
Get started
Want to contribute?

Get Rewarded: Get up to €50 credit on your account for every tutorial you write and we publish!

Find out more