Setup and Install Docker in a Promox LXC Conainer
Containers are a lightweight alternative to fully virtualized machines (VMs). They use the kernel of the host system that they run on, instead of emulating a full operating system (OS). This means that containers can access resources on the host system directly.
The runtime costs for containers is low, usually negligible. However, there are some drawbacks that need be considered:
-
Only Linux distributions can be run in Proxmox Containers. It is not possible to run other operating systems like, for example, FreeBSD or Microsoft Windows inside a container.
-
For security reasons, access to host resources needs to be restricted. Therefore, containers run in their own separate namespaces. Additionally some syscalls (user space requests to the Linux kernel) are not allowed within containers.
Proxmox VE uses Linux Containers (LXC) as its underlying container technology. The “Proxmox Container Toolkit” (pct) simplifies the usage and management of LXC, by providing an interface that abstracts complex tasks.
Containers are tightly integrated with Proxmox VE. This means that they are aware of the cluster setup, and they can use the same network and storage resources as virtual machines. You can also use the Proxmox VE firewall, or manage containers using the HA framework.
Our primary goal is to offer an environment that provides the benefits of using a VM, but without the additional overhead. This means that Proxmox Containers can be categorized as “System Containers”, rather than “Application Containers”.
The above was sited from the Proxmox VE website.
Download the Turnkey Core template
To setup and install Docker in a Proxmox LXC Conainer, you will have to download the Turnkey Core template to your storage.
1. Click on your storage then click on the templates button.
2. Search for the core template and click download.
3. When it's done you can click the "Create CT" button in the upper right corner.
4. Set your hostname and password and be sure to UNCHECK "Unprivileged container" or this will not work. Now move on to the Template tab.
5. Select the storage where you downloaded the Turnkey Core template then choose the template.
6. In the Storage tab choose where you want the container to use storage. For the disk size I recommend at-least 20gb of space. This depends on what you plan on doing with the container. For example if you plan on downloading a bunch of files, you may want a larger size disk.
7. On the CPU tab, I usually put 4 cores but this is overkill for a container. This depends on the processor you have in your system.
8. On the Memory tab I usually allocate 2gb for containers.
9. On the Network tab I let the DHCP host assign the IP automatically.
10. On the DNS tab I just use my gateway IP.
11. Confirm your settings and make sure you DO NOT tick "Start after created". Click finish and let the container create.
12. Once done, you will see "TASK OK". Click the X in the upper corner and proceed to the next step.
13. Select the container and then click on Options then double click on Features.
14. Tick Nesting then click ok.
15. Now you can start your container and view the console.
This will start the container and run the install script then assign an IP to your container. Once done you will need to login using root and the password you chose when you created the container in step 4.
16. Now we have to go through the Turnkey setup. Skip the API entry.
17. Skip the notifications.
18. Install security updates.
This will take you to the final screen and will show you what the access IP and ports are for the appliance services. It's important to make a note of these incase you need them for future use.
19. Press CTRL+C to clear the console and now you can update the system by typing the commands below. Since we only use root in Proxmox, you do not need to use sudo for any commands through the console.
apt-get update
then
apt-get upgrade
Install Docker on your Promox Container
Run the following commands one at a time.
apt install docker.io
systemctl enable docker
systemctl start docker
Now make sure Docker is running
systemctl status docker
Install Portainer
This is completely optional but I wanted to add this in here just in-case you wanted a Docker UI. Run the following command to install Portainer 2.0
docker run -d \
--name="portainer" \
--restart on-failure \
-p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce
Once completed, visit the IP of your container and port 9000. Example: 192.168.1.168:9000.
If you forgot the IP of your container, open the console and type
ip addr
Press enter and find your container IP. It's usually towards the top.
Entry written by Jeremy or Geeked on YouTube.
1 Comment
Hi, I'm running Proxmox 6.3-3 and followed your description above. But "systemctl start docker" throws an error:
--snip-- Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details. --snip--
On running the command "apt install docker.io" I got this output:
--snip-- [email protected] ~# apt install docker.io Reading package lists... Done Building dependency tree
Reading state information... Done Suggested packages: docker-doc aufs-tools btrfs-progs debootstrap rinse xfsprogs zfs-fuse | zfsutils Recommended packages: cgroupfs-mount needrestart xz-utils The following NEW packages will be installed: docker.io 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/53.5 MB of archives. After this operation, 238 MB of additional disk space will be used. debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package docker.io. (Reading database ... 27513 files and directories currently installed.) Preparing to unpack .../docker.io_18.09.1+dfsg1-7.1+deb10u2_amd64.deb ... Unpacking docker.io (18.09.1+dfsg1-7.1+deb10u2) ... Setting up docker.io (18.09.1+dfsg1-7.1+deb10u2) ... Created symlink /etc/systemd/system/sockets.target.wants/docker.socket -> /lib/systemd/system/docker.soc ket. Processing triggers for systemd (241-7~deb10u6) ... Processing triggers for man-db (2.8.5-2) ... [master 498c66b] committing changes in /etc made by "apt install docker.io" 3 files changed, 1 insertion(+), 2 deletions(-) delete mode 120000 systemd/system/docker.service delete mode 120000 systemd/system/docker.socket create mode 120000 systemd/system/sockets.target.wants/docker.socket Enumerating objects: 1299, done. Counting objects: 100% (1299/1299), done. Delta compression using up to 2 threads Compressing objects: 100% (783/783), done. Writing objects: 100% (1299/1299), done. Total 1299 (delta 108), reused 1291 (delta 105) --snip--
That seems to be okay. The next command "systemctl enable docker" seems to be okay, too:
--snip-- [email protected] ~# systemctl enable docker Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable docker --snip--
The command "systemctl status docker.service" shows:
--snip-- [email protected] ~# systemctl status docker.service
Feb 10 10:52:13 docker systemd[1]: docker.service: Service RestartSec=100ms expired, scheduling restart. Feb 10 10:52:13 docker systemd[1]: docker.service: Scheduled restart job, restart counter is at 3. Feb 10 10:52:13 docker systemd[1]: Stopped Docker Application Container Engine. Feb 10 10:52:13 docker systemd[1]: docker.service: Start request repeated too quickly. Feb 10 10:52:13 docker systemd[1]: docker.service: Failed with result 'exit-code'. Feb 10 10:52:13 docker systemd[1]: Failed to start Docker Application Container Engine. --snip--
Do you have an idea why there is a problem starting docker?
Regards, Area