github上创建dockerfile项目
登录github,添加新项目 填写项目基本信息完成后我们就在github上创建了一个项目,我们需要在本机或服务器上的源码提交到github上。mkdir gitDockerfile//创建项目目录git init//初始化gitgit clone git@github.com:tonyxinminghui/gitDock
登录github,添加新项目
填写项目基本信息
完成后我们就在github上创建了一个项目,我们需要在本机或服务器上的源码提交到github上。
mkdir gitDockerfile
//创建项目目录
git init
//初始化git
git clone git@github.com:tonyxinminghui/gitDockerfile.git
vim Dockerfile
//编写dockerfile文件(内容见上期)
touch abc.txt
//创建Dockerfile中的所添加文件
git add abc.txt
git commit -m "this file needs to be created before add"
mkdir webapp
cd webapp
touch web.txt
git add web.txt
git commit -m "this file needs to be created before add"
git push
- 后项目构建完毕
这样我们就可以通过github上的url进行镜像的构建
如:
docker build -t tonyxinminghui/test:v1 git://github.com/tonyxinminghui/gitDockerfile.git
//这里注意对比需要修改
Sending build context to Docker daemon 51.2 kB
Step 1 : FROM ubuntu:latest
—> f753707788c5
Step 2 : MAINTAINER Tony “445241843@qq.com”
—> Using cache
—> 9a074bfd4e0f
Step 3 : USER root
—> Using cache
—> cedca328fccd
Step 4 : RUN apt-get update
—> Using cache
—> 49cce3ae4c16
Step 5 : RUN apt-get install -y nginx
—> Using cache
—> c9e03a2f0d91
Step 6 : RUN touch test.txt && echo “abc” >> abc.txt
—> Using cache
—> 807c2c062ee1
Step 7 : EXPOSE 80 8080 1038
—> Using cache
—> f0d506658722
Step 8 : ADD abc.txt /opt/
—> Using cache
—> 4892dfa3727c
Step 9 : ADD /webapp /opt/webapp
—> abae120cd55c
Removing intermediate container d4230a467bcd
Step 10 : ADD https://www.baidu.com/img/bd_logo1.png /opt/
Downloading [==================================================>] 7.877 kB/7.877 kB
—> 9fdbe9da55bf
Removing intermediate container 6d5c6e7ee833
Step 11 : ENV WEBAPP_PORT 9090
—> Running in 9fd09b8ceb91
—> 92e56f844321
Removing intermediate container 9fd09b8ceb91
Step 12 : WORKDIR /opt/
—> Running in a6386b738614
—> 3d7e8f2b8697
Removing intermediate container a6386b738614
Step 13 : ENTRYPOINT ls
—> Running in c9ee13e8d510
—> d3d49e7861a5
Removing intermediate container c9ee13e8d510
Step 14 : CMD -a -l
—> Running in 1f6fef7bc226
—> b102cfec50d5
Removing intermediate container 1f6fef7bc226
Step 15 : VOLUME /data /var/www
—> Running in e1f3ff703618
—> d29decd7a2e7
Removing intermediate container e1f3ff703618
Step 16 : ONBUILD add ./app/src
—> Running in 844234e3a5a4
—> f75a589fc8e0
Removing intermediate container 844234e3a5a4
Step 17 : ONBUILD run echo “on build excuted” >> onbuild.txt
—> Running in d05c838a5451
—> d86e5ebbbee8
Removing intermediate container d05c838a5451
Successfully built d86e5ebbbee8
更多推荐
所有评论(0)