10.3. Setting Up Docker in Virtuozzo Containers

The current version of Virtuozzo Hybrid Server supports Docker containers inside Virtuozzo Hybrid Server system containers. You can install Docker in a Virtuozzo container from a Virtuozzo Hybrid Server’s Docker application template, from the official Docker repository as described in the Docker installation guide, or from your favorite OS repository. If you install Docker from the Docker or OS repository, make sure that your Docker version uses the overlayfs storage driver (for more information on Docker storage drivers, see https://docs.docker.com/engine/userguide/storagedriver/selectadriver/).

In the current version of Virtuozzo Hybrid Server, you can run Docker in containers based on CentOS 7, Debian 8, Ubuntu 14.04 and 16.04, and Virtuozzo Linux 7. The Virtuozzo container will just need a network connection and enough diskspace and RAM to run the Docker containers you need.

To set up Docker in a Virtuozzo container, do the following:

  1. Create a Virtuozzo container based on one of the aforementioned guest operating systems. For example:

    # prlctl create MyCT --vmtype ct --ostemplate centos-7-x86_64
  2. Configure network in the Virtuozzo container:

    # prlctl set MyCT --netif_add eth0
    # prlctl set MyCT --ifname eth0 --dhcp yes --network Bridged

    For more details, see Configuring Network Settings.

  3. Start the Virtuozzo container. For example:

    # prlctl start MyCT
  4. Install Docker in the Virtuozzo container:

    # prlctl exec MyCT yum install docker -y
  5. Start the Docker daemon:

    # prlctl exec MyCT systemctl start docker.service

The Virtuozzo container is now ready to run Docker containers.

To check that Docker is installed properly, you can create and run test Docker containers in the Virtuozzo Container. For example, MySQL and Wordpress:

  1. If required, increase container RAM and disk space. For example:

    # prlctl set MyCT --memsize 4G --device-set hdd0 --size 50G
  2. Launch MySQL:

    # prlctl exec MyCT docker run --name test-mysql -e MYSQL_ROOT_PASSWORD=123qwe -d mysql
  3. Launch WordPress:

    # prlctl exec MyCT docker run --name test-wordpress --link test-mysql:mysql -p 8080:80 \
    -d wordpress
  4. Visit the IP address of the Virtuozzo container on port 8080. You should see a standard WordPress installation screen.

10.3.1. Setting Up Docker for Running in Swarm Mode

Virtuozzo Hybrid Server supports running Docker in swarm mode inside Virtuozzo containers. Swarm mode is enabled by either creating a swarm or joining an existing swarm. A swarm is a cluster of Docker nodes.

To be able to run Docker in swarm mode, you need to set up Docker in a Virtuozzo container as follows:

  1. Perform steps 1-4 from the instruction given in Setting Up Docker in Virtuozzo Containers.

  2. Create the .dockerenv file in the container:

    # prlctl exec MyCT touch  /.dockerenv
  3. Load the ip_vs_ftp module on the server:

    # modprobe ip_vs_ftp
  4. Start the Docker daemon:

    # prlctl exec MyCT systemctl start docker.service

Once Docker is set up in the Virtuozzo container, you can proceed to creating a swarm. To do this, refer to Getting started with swarm mode.

10.3.2. Restrictions and Limitations for Docker in Virtuozzo Containers

  1. Virtuozzo Hybrid Server 7 does not support checkpointing and live migration of containers with Docker installed.
  2. Virtuozzo Hybrid Server 7 supports only overlayfs storage driver for Docker inside Virtuozzo containers.
  3. Modules and third party add-ons that depend on operations prohibited in containers (loading of kernel modules, mounting of block devices, direct access to physical hardware) may not work in containers.

Please contact Virtuozzo technical support in case of any issues with Docker-related solutions.