[Docker]Dockerfile定制容器
需要部署的网页
cat > /usr/local/docker/myshop/index.jsp <<‘EOF‘ Hello World ! EOF
创建容器配置文件
mkdir -p /usr/local/docker/myshop cat > /usr/local/docker/myshop/Dockerfile <<‘EOF‘ FROM tomcat:latest # 创建文件夹 RUN mkdir /usr/local/tomcat/webapps/ROOT # 复制文件 COPY index.jsp /usr/local/tomcat/webapps/ROOT EOF
创建容器
[ myshop]# docker build -t myshop . Sending build context to Docker daemon 3.072kB Step 1/3 : FROM tomcat:latest ---> 31a47677561a Step 2/3 : RUN mkdir /usr/local/tomcat/webapps/ROOT ---> Running in 78de34ca9ae8 Removing intermediate container 78de34ca9ae8 ---> 7fdc8ab7508e Step 3/3 : COPY index.jsp /usr/local/tomcat/webapps/ROOT ---> 5eba0cd03308 Successfully built 5eba0cd03308 Successfully tagged myshop:latest
查看镜像
[ myshop]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE myshop latest 2b6a97a4c5be 56 seconds ago 529MB
运行自定义的容器
[ myshop]# docker run -p 8080:8080 -d myshop 42111bdab34e172a777fde5d310ed5f251c09bff46c400fbf3f5b929d2321f1c
Dockerfile上下文
在当前目录下打包给docker进程,需要将所有待打包文件放置在此路径下
[ myshop]# tree . ├── Dockerfile └── pages └── index.jsp 1 directory, 2 files
修改配置文件
[ myshop]# cat > /usr/local/docker/myshop/Dockerfile <<‘EOF‘ FROM tomcat:latest # 创建文件夹 RUN mkdir /usr/local/tomcat/webapps/ROOT # 复制文件 COPY pages/index.jsp /usr/local/tomcat/webapps/ROOT EOF
重新构建容器
[ myshop]# docker build -t myshop . Sending build context to Docker daemon 3.584kB Step 1/3 : FROM tomcat:latest ---> 31a47677561a Step 2/3 : RUN mkdir /usr/local/tomcat/webapps/ROOT ---> Using cache ---> 6acd843144d1 Step 3/3 : COPY pages/index.jsp /usr/local/tomcat/webapps/ROOT ---> 790739f2e70f Successfully built 790739f2e70f Successfully tagged myshop:latest
END
相关推荐
xysoul 2020-11-03
ShangQuan0 2020-09-10
fearlessxjdx 2020-09-04
Crystalqy 2020-08-15
yss0 2020-08-19
young依然 2020-08-17
TaoTaoFu 2020-08-03
vtnews 2020-07-29
小信 2020-07-28
白开水 2020-07-19
lihy0 2020-07-18
糊一笑 2020-07-04
wzg0wzg 2020-07-04
pigsmall 2020-07-04
VFCSDN 2020-07-04
qdqht00 2020-06-28
tosim 2020-06-24
tianlong 2020-06-21
yudiewenyuan 2020-06-21