Docker learning (six) Dockerfile build a custom image
Foreword
By previous article may know how to build a service using a mirror, but a mirror of how to construct your own it, docker provides dockerfile allow ourselves to construct a mirror image of their own
What is dockerfile
Is a text file containing commands for combining mirror
Docker image generated automatically by step instructions by reading Dockerfile
Real - custom packaging tomcat image
Write Dockerfile
mkdir -p /usr/local/docker/bk-web-dockerfile
cd /usr/local/docker/bk-web-dockerfile
Upload bk-web package to this /usr/local/docker/bk-web-dockerfile
directory
vim Dockerfile
The following entry
FROM tomcat:latest
MAINTAINER albk.tech
WORKDIR /usr/local/tomcat/webapps
ADD bk-web ./bk-web
Compile dockerfile generated image
docker build -t albk.tech/bkwebapp:1.0 .
docker images
Run a custom image
docker run -d -p 8000:8080 albk.tech/bkwebapp:1.0
Tomcat into the interior of the container
docker ps
docker exec -it 43825ec40a2 /bin/bash
After entering the container, automatically enters the configuration directory Dockerfile / usr / local / tomcat / webapp can see the list bk-web
View the contents of bk-web
There is no access within the test vessel problems
8080 in tomcat container port access
Test host access
8000 access port in the host machine
Test browser access tomcat
Here our project is to build up, it can be accessed directly through the browser
Problems encountered
You can not access from the browser to tomcat
The reason may be due to a firewall, use the command in the development and testing stage systemctl stop firewalld
to turn off the firewall.
Written in the last
The material in this article has been packed needed, Baidu cloud sharing, you can focus public number albk , reply command " Docker Dockerfile " get
Related Articles will be starting public number, you can focus on the public number albk , you can get a lot of attention after learning video
Hope you love technology together to exchange and obtain the latest information and learning resources can focus on public number albk, personal blog !