首先Docker入门看这里
CentOS 7 安装 Docker
安装直接按照官方文档即可,看这里
如果安装出现如下错误:
--> Processing Conflict: moby-containerd-1.3.6+azure-1.x86_64 conflicts containerd
--> Processing Conflict: moby-runc-1.0.0~rc10+azure-2.x86_64 conflicts runc
--> Finished Dependency Resolution
Error: moby-containerd conflicts with containerd.io-1.2.13-3.2.el7.x86_64
Error: moby-runc conflicts with containerd.io-1.2.13-3.2.el7.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
需要先执行,看这里:
curl https://packages.microsoft.com/config/rhel/7/prod.repo >/etc/yum.repos.d/microsoft-prod.repo
rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
安装 mongo
- 创建要挂载的目录
cd /home/
mkdir mongo/
mkdir mongo/config/
mkdir mongo/db/
- 拉取镜像
docker pull mongo
- 创建容器
docker run -d -p 27017:27017 --name=mongo1 -v=/home/mongo/config:/data/configdb -v=/home/mongo/db:/data/db mongo
--name为容器名称
-p为端口映射,主机端口:容器端口
-v为数据卷挂载,主机绝对路径:容器路径
安装 mongo-express
mongo-express为mongodb的用户界面,可以方便的操作mongodb
安装成功后可通过http://xxx:8081访问
- 拉取镜像
docker pull mongo-express
- 创建容器
docker run -it -d -p 8081:8081 -e ME_CONFIG_MONGODB_SERVER="127.0.0.1" --name="mongoweb" mongo-express
-e ME_CONFIG_MONGODB_SERVER="127.0.0.1" 为设置mogodb服务器地址,详细配置看mongo-express