Docker learning (six) Dockerfile build a custom image

Docker learning (six) Dockerfile build a custom image

Enter a description of the picture here


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-dockerfiledirectory

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

Enter a description of the picture here

Run a custom image

docker run -d -p 8000:8080 albk.tech/bkwebapp:1.0

Enter a description of the picture here

Tomcat into the interior of the container

docker ps

Enter a description of the picture here

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

Enter a description of the picture here

View the contents of bk-web

Enter a description of the picture here

There is no access within the test vessel problems

8080 in tomcat container port access

Enter a description of the picture here

Test host access

8000 access port in the host machine

Enter a description of the picture here

Test browser access tomcat

Enter a description of the picture here

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 firewalldto 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 !

Guess you like

Origin www.cnblogs.com/albk/p/12219929.html