Dockerfile 示例一:创建一个MongoDB的镜像
来源:互联网 发布:2012中国网络购物规模 编辑:程序博客网 时间:2024/05/16 08:33
如何使用Dockerfiles
使用Dockerfiles和手工使用Docker Daemon运行命令一样简单。脚本运行后输出为新的镜像ID。
# Build an image using the Dockerfile at current location
# Example: sudo docker build -t [name] .
sudo docker build -t my_mongodb .
Dockerfile 示例一:创建一个MongoDB的镜像
在这部分中,我们讲一步一步创建一个Dockfile,这个Dockerfile可用于构建MongoDB镜像进而构建MongoDB容器。
创建一个Dockerfile
使用nano文本编辑器,让我们创建Dockerfile。
sudo nano Dockerfile
定义文件和它的目的
让阅读者明确Dockerfile的目的永远是必要的。为此,我们通常从注释开始写Dockerfile。
############################################################
# Dockerfile to build MongoDB container images
# Based on Ubuntu
############################################################
设置基础镜像
# Set the base image to Ubuntu
FROM ubuntu
定义作者
# File Author / Maintainer
MAINTAINER Example McAuthor
设置命令与参数下载MongoDB
################## BEGIN INSTALLATION ######################
# Install MongoDB Following the Instructions at MongoDB Docs
# Ref: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
# Add the package verification key
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
# Add MongoDB to the repository sources list
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list
# Update the repository sources list once more
RUN apt-get update
# Install MongoDB package (.deb)
RUN apt-get install -y mongodb-10gen
# Create the default data directory
RUN mkdir -p /data/db
##################### INSTALLATION END #####################
设置MongoDB端口
# Expose the default port
EXPOSE 27017
# Default port to execute the entrypoint (MongoDB)
CMD ["--port 27017"]
# Set default container command
ENTRYPOINT usr/bin/mongod
保存Dockerfile。
构建镜像
使用上述的Dockerfile,我们已经可以开始构建MongoDB镜像
sudo docker build -t my_mongodb .
0 0
- Dockerfile 示例一:创建一个MongoDB的镜像
- Dockerfile 示例二:创建一个Nginx的镜像
- Dockerfile创建镜像
- Dockerfile 创建 tomcat 镜像
- dockerfile 创建 ssh 镜像
- dockerfile创建nginx镜像
- Dockerfile 创建简单镜像
- 使用Dockerfile创建一个带 ssh 服务的基础镜像
- 通过Dockerfile创建支持SSH服务的CentOS镜像
- 使用DockerFile创建ubuntu下的tomcat镜像
- 使用Dockerfile创建自己的docker镜像
- 通过Dockerfile创建支持SSH服务的CentOS镜像
- 通过Dockerfile创建支持SSH服务的CentOS镜像
- 通过Dockerfile创建SSH服务的CentOS镜像
- 通过Dockerfile创建nginx服务的Centos镜像
- 通过Dockerfile创建Mysql服务的Centos镜像
- 通过Dockerfile创建JDK8的CentOS镜像
- 通过Dockerfile创建Tomcat的CentOS镜像
- 函数调用缺少参数列表;请使用“&****Dlg::getThread”创建指向成员的指针”--多线程函数调用
- Android Service onStartCommand()介绍
- Trie树
- 练习3-L
- OC 中类的声明和定义
- Dockerfile 示例一:创建一个MongoDB的镜像
- 企业设备管理的十大症结
- MySQL指定数据文件位置
- 配置pl/sql 连接远程oracle服务器
- php如何统计下载成功次数
- AVL树详解
- 几款Java反编译软件
- iOS自定义UITableViewCell registerNib: 与 registerClass: 的区别
- 不同编译器 关于程序占用系统ROM、RAM情况的查看方法