docker+nexus+jenkins+java+maven
docker 使用ubuntu下安装docker$ sudo apt-get install docker.iodocker获取基础镜像$ docker pull ubuntu:17.04创建一个简单镜像$ mkdir docker-jmnj$ cd docker-jmnj$ touch Dockerfile编辑Dockerfile# 这里是注释# 设置继承自哪个镜像FR
·
docker 使用
- ubuntu下安装docker
$ sudo apt-get install docker.io
- docker 获取基础镜像
$ docker pull ubuntu:17.04
- 创建一个简单镜像
$ mkdir docker-jmnj
$ cd docker-jmnj
$ touch Dockerfile
- 编辑Dockerfile
# 这里是注释
# 设置继承自哪个镜像
FROM ubuntu:17.04
# 下面是一些创建者的基本信息
MAINTAINER zjkorder (zjkorder@foxmail.com)
# 在终端需要执行的命令
RUN mkdir /alidata
- 编译docker
$ sudo docker build -t="zjkorder/dokcer-jmnj:v1" .
# 参数:
# -t 标记来添加 tag,指定新的镜像的用户和镜像名称信息。
# “.” 是 Dockerfile 所在的路径(当前目录),也可以替换为一个具体的Dockerfile 的路径。
- 启动docker
# 以交互方式运行docker
$ docker run -it zjkorder/dokcer-jmnj:v1 /bin/bash
# 运行docker时指定配置
# 参数:
# -i:表示以“交互模式”运行容器,-i 则让容器的标准输入保持打开
# -t:表示容器启动后会进入其命令行,-t 选项让Docker分配一个伪终端(pseudo-tty)并绑定到容器的标准输入上
# -v:表示需要将本地哪个目录挂载到容器中,格式:-v <宿主机目录>:<容器目录>,-v 标记来创建一个数据卷并挂载到容器里。在一次 run 中多次使用可以挂载多个数据卷。
# -p:指定对外80端口
# 不一定要使用“镜像 ID”,也可以使用“仓库名:标签名”
docker 配置java+maven 环境变量
- 复制jdk 和maven 压缩包到 docker 镜像下到alidata文件
- 设置maven setting.xml(nexus 会用到)
<?xml version="1.0" encoding="UTF-8"?>
<pluginGroups>
<pluginGroup>org.sonatype.plugins</pluginGroup>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</url>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
- Dockerfile 设置环境变量
更多推荐
所有评论(0)