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
- Managed Server with enabled SSH access
Step 1 - Install udocker
Download and install udocker.
- Always check on github for newer stable versions
cd
wget https://github.com/indigo-dc/udocker/releases/download/1.3.16/udocker-1.3.16.tar.gz
tar xzvf udocker-1.3.16.tar.gz
export PATH="/usr/home/holu/udocker-1.3.16/udocker:$PATH"
export PROOT_TMP_DIR="/usr/home/holu/.tmp"
echo "PATH=\"/usr/home/holu/udocker-1.3.16/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.16/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.