Centos7 Cwp Docker Image
这是一个启用systemD并预装CentOS Web Panel(CWP)的CentOS7 Docker镜像,支持快速部署Web管理面板,首次运行会自动完成CWP的安装配置。
This is CentOS 7 image built with systemD and CWP (Centos Web Panel) for your convenience.
when run the container from this image for the first time it will install and configure CWP for us. when first start it will take long time to install so you have to be patient (25min-40min).If you prefer to use our already pre-installed Centos Web Panel image which we recommend to use first then have a look here:
https://hub.docker.com/r/multitech/cwp
before running the container we need to create couple of folders in our host so we can mount them in the container for backup and also for housing the hosting accounts file and the actual CWP backend settings. best is to create a folder inside your host root directory (/) not the root folder (/root) and name it (cwp-data). in folder cwp-data , create another 3 folders and call them (backup) & (home) & (cwp) .
before running the container we need to make sure our host is not using port 53, as we need to map this port to our CWP container to make sure that the DNS function is working in CWP. to free port 53 in ubuntu machine assuming that our host is ubuntu, please follow this LINK
now lets run our container and i will explain it's code parts.
to run the container from this image (don't run command yet, read below the command for Hostname and IP set):
docker run -d --cap-add=SYS_ADMIN --cap-add=NET_ADMIN --cap-add=CHOWN --cap-add=DAC_READ_SEARCH --cap-add=SETGID --cap-add=SETUID --cap-add=NET_BIND_SERVICE --cap-add=SYS_CHROOT --cap-add=SYS_NICE -ti -e container=docker --name Centos-CWP --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /cwp-data/home:/home -v /cwp-data/backup:/backup -v /cwp-data/vmail:/var/vmail -v /cwp-data/cwp:/usr/local/cwp --device=/dev/fuse --tmpfs /run --tmpfs /run/lock -p 80:80 -p 443:443 -p 53:53 -p 55:22 -p 2030:2030 -p 2031:2031 -p 3306:3306 -p 21:21 -p 20:20 -p 4242:4242 -p 4243:4243 -p 2082:2082 -p 2083:2083 -p 25:25 -p 110:110 -p 143:143 -p 465:465 -p 587:587 -p 993:993 -p 995:995 -p 2086:2086 -p 2087:2087 -p 2095:2095 -p 2096:2096 -p 82:82 -p 8181:8181 -p 8443:8443 -p 2304:2304 multitech/centos7-cwp:latest /usr/sbin/init
in the docker run command it's better that we pre selected the hostname and the ip address. the ip address is optional but for the hostname it's a must use as it will save us the trouble later on configuring the CWP. here the 2 options:
-h server.example.com (CHANGE this to yours)
--ip=172.17.0.3 (change this to your local docker range assigned)
and here how we include both:
docker run -h server.example.com --ip=172.17.0.3 -d --cap-add=SYS_ADMIN --cap-add=NET_ADMIN --cap-add=CHOWN --cap-add=DAC_READ_SEARCH --cap-add=SETGID --cap-add=SETUID --cap-add=NET_BIND_SERVICE --cap-add=SYS_CHROOT --cap-add=SYS_NICE -ti -e container=docker --name Centos-CWP --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /cwp-data/home:/home -v /cwp-data/backup:/backup -v /cwp-data/vmail:/var/vmail -v /cwp-data/cwp:/usr/local/cwp --device=/dev/fuse --tmpfs /run --tmpfs /run/lock -p 80:80 -p 443:443 -p 53:53 -p 55:22 -p 2030:2030 -p 2031:2031 -p 3306:3306 -p 21:21 -p 20:20 -p 4242:4242 -p 4243:4243 -p 2082:2082 -p 2083:2083 -p 25:25 -p 110:110 -p 143:143 -p 465:465 -p 587:587 -p 993:993 -p 995:995 -p 2086:2086 -p 2087:2087 -p 2095:2095 -p 2096:2096 -p 82:82 -p 8181:8181 -p 8443:8443 -p 2304:2304 multitech/centos7-cwp:latest /usr/sbin/init
note that we have mounted volumes to the container to store our Web Panel hosted account, settings and also the backup: -v /cwp-data/home:/home -v /cwp-data/backup:/backup -v /cwp-data/cwp:/usr/local/cwp
in our host at the root directory (/) not the root folder (/root), i have created a folder called cwp-data and inside that folder i created another 3 folders: home, backup and cwp . if it happened and we killed the container then we start it again, we need to use the backup/restore function inside CWP to restore the backup by selecting where (accountname.tar.gz) location and restore it.
when the container first start, our cwp-install script will start and check if the cwp is installed then it will exit otherwise it will install the cwp for us and update the system. it will take long time to install (minimum of 25min to complete).
we can see the progress of the installation in the container log in portainer or by going into attach option in portainer for that container. once the installation is done, login to the CWP interface is disabled because we haven't created root password for the container, so we have to log into the container console and do: passwd
to log inside the container to set the root password using terminal at host without portainer we do:
docker exec -it Centos-CWP passwd
after that we can just use the browser and browse to [***] public ip):2031/ to access cwp interface. username is: root and for the password whatever we set it to earlier.
first thing we should do after login is start failed start services if any, like FTP, SSH and PostFix mail services.
then we need to enable the firewall and install ModSecurity.
note: when accessing the container externally using SSH, we need to use port 55 as we already mapped port 55 on host to port 22 on the CWP container.
for the capabilities, our cwp needs:
NET_ADMIN and SYS_ADMIN as a must
- CHOWN
- DAC_READ_SEARCH
- SETGID
- SETUID
- NET_BIND_SERVICE
- SYS_CHROOT
- SYS_NICE
the following volumes we must use them to allow the D-BUS services and enable systemD in the container:
-v /var/run/docker.sock:/var/run/docker.sock
-v /sys/fs/cgroup:/sys/fs/cgroup:ro
the following temporary mounts should be used too to function properly with the services, otherwise many services will fail:
--device=/dev/fuse
--tmpfs /run
--tmpfs /run/lock
we must use the following for CMD or EnteryPoint to start systemD services correctly:
/usr/sbin/init
Other:
can we use docker-compose instead of docker run?
here is the docker-compose.yaml:
__CODE_TOKEN_0__
镜像拉取方式
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
轩辕镜像加速拉取命令点我查看更多 centos7-cwp 镜像标签
DockerHub 原生拉取命令
用户好评
来自真实用户的反馈,见证轩辕镜像的优质服务