DevOps : Build your docker repository for example

1. Install docker on Ubuntu

Please refer to

https://linuxconfig.org/how-to-install-docker-on-ubuntu-18-04-bionic-beaver

2.  Check and Download JavaSimpleProject.zip  include dockerfile and java code

Zip file includes:

src/main maven project folder
Dockerfile for docker build including maven,tomcat installation
pom.xml for maven build
start.sh start tomcat to run java application

Note, in Dockerfile, you can change

FROM ubuntu:latest

into

FROM ubuntu:18.04

3. Change to your local dir where Dockerfile locates

Use command:

   docker build .

After that the java8, tomcat, maven will be setup in your docker container

After running, SimpleServlet-1.war will be generated.

4. To check java project runs normally, then input command will get output

   curl http://localhost:8080/SimpleServlet-1/hello

Then you can modify code or add your applications.

5. Register an account in https://hub.docker.com/ e.g. testhub 6. Tag docker image docker tag <your docker imageid>  <your account/your tagname:version> e.g.

 

   docker tag bd5812223e6 testhub/mydocker:v1.0

7. Input command, then input your dockerhub account/password

   docker login

8. Push docker into your remote repository e.g.

   docker push testhub/mydocker

9. Then in future you can base this repo to further devops, e.g.

   from mydockerhubaccount/mydocker:v1.0

Use it as your Dockerfile

Leave a Reply

Your email address will not be published. Required fields are marked *