How to make docker filešŸ ...??

How to make docker filešŸ ...??

Ā·

1 min read

We will make a docker file for a simple java application so firstly we have to clone it.
Copy this link: https://github.com/prem14choudhary/simple-java-docker.git

Hereā€™s the solution':

  1. ssh to your EC2 instance.

  2. Run for making project folder: mkdir projects

  3. Run for cloning it: git clone https://github.com/prem14choudhary/simple-java-docker.git

  4. Run : cd simple-java-docker/

  5. Run for removing existing docker file: rm -v Dockerfile

  6. Run to make new docker file: vim Dockerfile.

Now i will giving the script, you have to enter in that vim editor. I will also giving explanation in brackets() donā€™t insert that.

FROM openjdk:17-jdk-alpine (for the enviroment and libraries the application need)

WORKDIR /app (for making a folder in the container where the the source code will be placed)

COPY src/Main.java /app/Main.java (for copy the source code in the container folder)

RUN javac Main.java (for compiling the Main.java after the container will be created)

CMD [ā€œjavaā€œ,ā€Mainā€] (it will run the container after creation)

To save this enter: esc button then :wq

Your Docker file is created.

Hari om tatsat


Ā