diff --git a/projects/container.md b/projects/container.md index 884e438..c904e6d 100644 --- a/projects/container.md +++ b/projects/container.md @@ -1,3 +1,84 @@ +Great choice going with Debian! To set up Docker within an LXC container on Proxmox, you will need to configure both the LXC container and the Debian OS to support Docker functionalities. Here’s a step-by-step guide to get you started: + +### Step 1: Prepare the Proxmox Host + +Before creating the LXC container, you need to ensure that the Proxmox host is ready to support nested virtualization. + +1. **Enable nesting on the host**: + - Edit the kernel parameters on the host. Open `/etc/default/grub` and modify the `GRUB_CMDLINE_LINUX_DEFAULT` line to include: + ``` + GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on" + ``` + - Update GRUB and reboot the host: + ```bash + update-grub + reboot + ``` + +### Step 2: Create the LXC Container + +When creating the LXC container in Proxmox, choose Debian as the template and ensure the container has sufficient resources (CPU, RAM) to handle Docker workloads. + +### Step 3: Configure the LXC Container for Docker + +After creating the container, modify its configuration to allow Docker-specific functionalities. + +1. **Edit the LXC configuration file**: + - Locate the configuration file for your LXC container. This will typically be in `/etc/pve/lxc/`. The configuration files are named by their VM ID, for example, `100.conf`. + - Add the following lines to the container’s configuration file to enable nesting and key kernel modules: + ``` + lxc.apparmor.profile: unconfined + lxc.cgroup.devices.allow: a + lxc.cap.drop: + lxc.arch: linux64 + lxc.net.0.veth.pair: eth0 + ``` + - Optionally, to ensure the filesystem behaves correctly with Docker, you might want to enable the following: + ``` + lxc.mount.auto: proc:rw sys:rw cgroup:rw + lxc.autodev: 1 + ``` +2. **Restart the LXC container** to apply these configuration changes. + +### Step 4: Install Docker in the Debian LXC Container + +1. **Access the LXC container** via SSH or the Proxmox console. +2. **Update the package repository and install required packages**: + ```bash + apt-get update + apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common + ``` +3. **Add Docker’s official GPG key**: + ```bash + curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - + ``` +4. **Set up the stable repository**: + ```bash + add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + ``` +5. **Install Docker Engine**: + ```bash + apt-get update + apt-get install docker-ce docker-ce-cli containerd.io + ``` +6. **Start and enable Docker**: + ```bash + systemctl start docker + systemctl enable docker + ``` + +### Step 5: Verify Docker Installation + +Run a test Docker container to ensure everything is working correctly. + +```bash +docker run hello-world +``` + +This setup should provide a solid foundation for running Docker within an LXC container on Proxmox using Debian. Remember to regularly update both the host and the container system to ensure security and stability. + +--- + When dealing with a container, the process for setting up SSH can differ slightly from setting up SSH on a traditional VM or physical server, particularly when it comes to enabling root access. Here are the steps you can follow, adjusted for container environments and root access: ### 1. Install SSH Server in the Container