无法在CentOS 6.9装Docker,如何创建其32位容器镜像?
Got it, since Docker CE dropped support for CentOS 6 entirely, you've got a few solid alternatives to build and run a CentOS 6.9 32-bit container image. Let's break them down:
Option 1: Use an Older Docker Version (1.13.x or Earlier)
Docker versions up to 1.13.x still supported CentOS 6. Here's how to set this up:
First, fix your CentOS 6 repos (since official repos are archived):
Edit/etc/yum.repos.d/CentOS-Base.repoto point to the CentOS 6 vault:[base] name=CentOS-6 - Base baseurl=http://vault.centos.org/6.9/os/i386/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [updates] name=CentOS-6 - Updates baseurl=http://vault.centos.org/6.9/updates/i386/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [extras] name=CentOS-6 - Extras baseurl=http://vault.centos.org/6.9/extras/i386/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6Install dependencies and older Docker:
yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://get.docker.com/rpm/1.13.0/centos-6/RPMS/i386/ yum install docker-engine-1.13.1-1.el6.i686Start Docker and build your image:
- Start the service:
service docker start - You can now use a Dockerfile based on the official (archived) CentOS 6 32-bit image, or build your own. For example, a minimal Dockerfile:
FROM centos:6.9-i386 RUN yum update -y && yum install -y your-packages-here CMD ["/bin/bash"] - Build with:
docker build -t centos69-32bit .
- Start the service:
Option 2: Use LXC (Linux Containers)
LXC has better support for older distributions like CentOS 6, and it's included in the CentOS 6 repos:
Install LXC and templates:
yum install -y lxc lxc-templatesCreate a CentOS 6.9 32-bit container:
lxc-create -n centos6-32 -t centos -- --release 6 --arch i386This will pull the necessary packages and set up a full CentOS 6.9 32-bit root filesystem.
Customize and export the image:
- Start the container:
lxc-start -n centos6-32 - Attach to it to install software/configure:
lxc-attach -n centos6-32 - When done, stop the container:
lxc-stop -n centos6-32 - Export the rootfs as a tarball (your reusable image):
tar -czf centos69-32bit-lxc.tar.gz /var/lib/lxc/centos6-32/rootfs/ - To reuse this image elsewhere, just unpack the tarball into a new LXC container's rootfs directory.
- Start the container:
Option 3: Manually Build a RootFS and Import to a Container Tool
If you want full control, build a CentOS 6.9 32-bit root filesystem from scratch, then import it into Docker (older version) or LXC:
Build the rootfs:
yum install -y yum-utils mkdir /tmp/centos6-rootfs yum --installroot=/tmp/centos6-rootfs --releasever=6 --arch=i386 groupinstall "Base" yum --installroot=/tmp/centos6-rootfs clean allImport to older Docker:
tar -C /tmp/centos6-rootfs -c . | docker import - centos69-32bit:customOr use with LXC:
- Create a new empty LXC container:
lxc-create -n centos6-custom -t empty - Replace its rootfs:
rm -rf /var/lib/lxc/centos6-custom/rootfs/* && tar -xf centos69-32bit.tar.gz -C /var/lib/lxc/centos6-custom/rootfs/ - Start it:
lxc-start -n centos6-custom
- Create a new empty LXC container:
Key Notes
- CentOS 6 is end-of-life, so always use the vault repos to avoid broken links.
- Older Docker versions won't get security updates, so only use this in isolated environments if possible.
- LXC is a lighter alternative without Docker's overhead, which might be better for legacy systems.
内容的提问来源于stack exchange,提问作者vico




