App containers like Docker are vulnerable to security risks. Docker inside an OpenVZ container is a nice solution to secure your containers!
I will explain how to configure Docker inside a container with CentOS 7.
Create a new container:
prlctl create CTNAME --vmtype ct --ostemplate centos-7-x86_64
Check your bridge config:
prlsrvctl net list
[[email protected] ~]$ prlsrvctl net list
Network ID Type Bound To Bridge Slave interfaces
Bridged bridged enp3s0 br0
Host-Only host-only virbr0
Add a new interface to your container:
prlctl set CTNAME --netif_add netif1
Set your IP-Address:
prlctl set CTNAME --ifname netif1 --ipadd YourIP/CIDR
Set your DNS IP-Address:
prlctl set CTNAME --ifname netif1 --nameserver 8.8.8.8
Set your gateway IP-Address:
prlctl set CTNAME --ifname netif1 --gw YourGatewayIP
Add netif1 to network ‘Bridged’:
prlctl set CTNAME --ifname netif1 --network Bridged
Using a dedicated/public server? Request and setup a virtual mac-address:
prlctl set CTNAME --device-set net1 --mac 00:1C:42:2D:74:00
Choose the container resources: Link
Start the container:
prlctl start CTNAME
Install Docker:
prlctl exec CTNAME yum install docker -y
Start Docker daemon:
prlctl exec CTNAME systemctl start docker.service
Setup SQL inside Docker:
prlctl exec CTNAME docker run --name mysql -e MYSQL_ROOT_PASSWORD=YourPassword -d mysql
Setup WordPress:
prlctl exec CTNAME docker run --name wordpress --link mysql:mysql -p 8080:80 \
-d wordpress
Yay! The installation has been completed!
Visit the IP-Address of your container on webport 8080.
Check the OpenVZ Guide for more information about networking etc.: Link
- OpenVZ 7 does not support checkpointing and live migration of containers with Docker installed.
- OpenVZ 7 supports only overlayfs storage driver for Docker inside Virtuozzo containers.
- 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.
Docker on OpenVZ or Virtuozzo Containers:
Docker on VM’s:
Thanks for reading this post! Was it useful? Let me know by leaving a comment