Docker mirror actual combat, create your own tomcat mirror and publish it to the remote warehouse

1. Create your own tomcat mirror

1. Prepare tomcat compressed package, jdk compressed package

Insert picture description here

2. Write the dockerfile file

Write the dockerfile file, officially named it Dockerfile, and build will automatically find this file, so there is no need to specify -f!

FROM centos
MAINTAINER ybg<[email protected]>

COPY readme.txt /usr/local/readme.txt

ADD jdk-8u281-linux-x64.tar.gz /usr/local
ADD apache-tomcat-9.0.34.tar.gz /usr/local/

RUN yum -y install vim

ENV MYPATH /usr/local
WORKDIR $MYPATH

ENV JAVA_HOME /usr/local/jdk1.8.0_281
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools/jar
ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.34
ENV CATALINA_BASH /usr/local/apache-tomcat-9.0.34
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin

EXPOSE 8080

CMD /usr/local/apache-tomcat-9.0.34/bin/startup.sh && tail -F /url/local/apache-tomcat-9.0.34/bin/logs/catalina.out

3. Build the image

docker build -t diytomcat .

Screenshot:
Insert picture description here

4. Start the mirror

docker run -d -p 8003:8080 --name ybgtomcat -v /home/ybg/build/tomcat/test:/usr/local/apache-tomcat-9.0.34/webapps/test -v /home/ybg/build/tomcat/tomcatlogs:/usr/local/apache-tomcat-9.0.34/logs diytomcat

Screenshot:
Insert picture description here
Test:
Access to port 8003 is successful!
Insert picture description here

5. Publish the project

Since we have mounted the volume, we only need to publish our project in the /home/ybg/build/tomcat/test directory. We can
create an index.html file in this directory.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>try</title>
</head>

<body>
<h1>
YBG 的第一个tomcat镜像!
</h1>
</body>

</html>

Create a new index.html
Insert picture description here
test on the host :
test directory under port 8003, the test is successful!
Insert picture description here

2. Publish your own mirror

1、DockerHub

1. Register a DockerHub account that can log in

Registered address: https://hub.docker.com/

2. Log in to the DockerHub account on your cloud server

docker login -u yybg 

Then enter the password, the password is correct to log in successfully!
Insert picture description here

3. Publish the image

 docker push 用户名/ybgtomcat:1.0

Note: The thing to push must be the username/container name: version number, otherwise push will be rejected, and the username/ybgtomcat is the name of your local mirror

Screenshot:
Insert picture description here
If your name is not username/container name at the beginning, you can modify it by command

docker tag 镜像id 用户名/容器名:版本号

Screenshot:
Insert picture description here

2. Alibaba Cloud Warehouse

1. Log in to Alibaba Cloud and find the container mirroring service

Insert picture description here

2. Create a mirror warehouse

Insert picture description here

After you select the local warehouse and
Insert picture description here
create it successfully, you can see the following information.
Insert picture description here
We click in and you can see a lot of information
Insert picture description here

3. Operate on the cloud server

Push the image to the Registry

 docker login --username=叶本国 registry.cn-shenzhen.aliyuncs.com
 docker tag [ImageId] registry.cn-shenzhen.aliyuncs.com/docker-ybg/docker-test:[镜像版本号]
 docker push registry.cn-shenzhen.aliyuncs.com/docker-ybg/docker-test:[镜像版本号]

Please replace the [ImageId] and [Image version number] parameters in the example according to the actual image information.
Screenshot:
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43520670/article/details/113665064