Overview
This page captures high level info to install docker and to build and deploy applications on docker
Steps
Install Docker
- Install docker
- For mac from the link https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac
- For windows from the link https://docs.docker.com/docker-for-windows/install/
- Once Docker is installed, you can run some basic commands from the following link
- https://docs.docker.com/docker-for-mac/
- Docker basics tutorial
- https://docs.docker.com/engine/getstarted/
There are multiple ways to build a docker image at multiple levels of integration. Following are the high level steps for building a docker image from war file.
- Create "Dockerfile" for guiding docker through the build process
- Create a file with name "Dockerfile"
- Add the webserver image to the Dockerfile, that you want to deploy your application as the base, as follows
- FROM tomcat:7-jre8
- Add maintainer name
- MAINTAINER "your mailid"
- Add copy command to the deploy path
- ADD {warfile-name} /usr/local/tomcat/webapps/
- Complete Dockerfile (sample)
- #Pull base image
- From tomcat:7-jre8
- # Maintainer
- MAINTAINER "dixitsatish34@gmail.com"
- # Copy to images tomcat path
- ADD ranking-service.war /usr/local/tomcat/webapps/
- Copy Dockerfile and war file to a directory
- Run the following command for Docker build
- docker build -t {image-name} .
- ex: docker build -t ranking-service .
Deploy & Run Docker Image
Use the following command to run the image build in previous step(with port bindings)
- docker run --rm -it -p {port binding} {image-name}
- ex: docker run --rm -it -p 8080:8080 ranking-service
References
https://docs.docker.com/docker-for-mac/install/
Enjoy Learning.
No comments:
Post a Comment