最近在折腾本地电脑win11下安装docker后,发现一个很好的开发方式,解决了之前在本地没法开发构建liunx C程序的问题。
1)本地搭建docker desktop环境;
2)拉取镜像
docker run -d centos
3)在运行的镜像里,安装必要的工具命令;
centos 8需要改下镜像源
cd /etc/yum.repos.d/
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
yum makecache
yum update -y
yum -y install vim
之后,就可以愉快的yum install 相关命令了。
4)将这个做好的容器,打个镜像。
docker commit 容器id centos:postgres
5) 下载postgres12.0源码,放置在本地目录。然后启动个新容器,将目录挂载到对应路径
docker run -v D:/git/postgresql-12.0:/home/postgres/postgresql-12.0 -it -d centos:postgres
6)在容器里进行make 构建,或者在本地修改本地,然后进容器构建。都可以的啦。