[DOCKER] How to make a Java container

Purpose

What if you manage your Java application environment with Kubernetes? First, build the development environment in a container to answer

Target

The functions are as follows Java

effect

You will be able to create a development environment from a Dockerfile. Even if you do not want to publish the configuration information locally or in a dedicated development environment, you can create the same environment anywhere by sharing the Dockerfile.

Premise

Docker installed Mac

work

First of all, preliminary research "Something" features like Java containers and ssh connection settings should have been accomplished by great men!

First, search on Docker Hub https://hub.docker.com/

I didn't have a good one, so I decided to make it from Dockerfile.

Creating an environment

To home directory cd

Open a terminal and create a working folder mkdir myproject

Go to working folder cd myproject

Create a Dockerfile vi Dockerfile

Dockerfile


FROM ubuntu:latest

ENV JAVA_HOME /usr/lib/jvm/java-8-oracle

RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
    apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository -y ppa:webupd8team/java && \
    apt-get update && \
    apt-get install -y oracle-java8-installer

CMD "/bin/bash"

Generate image from Dockerfile docker build -t testtest . Don't forget the last "."

After a short time

Successfully built 51fe1ec9021b Successfully tagged test:latest There is a display like this, and the image is finished.

Make sure the image exists docker images A list of owned images is output, and if there is "testtest", it is OK

Run the image docker run -i -t testtest java -version

OK if the output is as follows

java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

Thank you for your hard work.

Recommended Posts

How to make a Java container
How to make a Java array
How to make a Java calendar Summary
How to make a Discord bot (Java)
Java --How to make JTable
How to make a JDBC driver
[Java] How to create a folder
How to make a splash screen
How to make a Jenkins plugin
How to make a Maven project
How to create a lightweight container image for Java apps
[Introduction to Java] How to write a Java program
How to print a Java Word document
How to make shaded-jar
How to make a groundbreaking diamond using Java for statement wwww
How to deploy a container on AWS Lambda
How to get a heapdump from a Docker container
How to display a web page in Java
I did Java to make (a == 1 && a == 2 && a == 3) always true
I wanted to make (a == 1 && a == 2 && a == 3) true in Java
How to convert a solidity contract to a Java contract class
How to make a lightweight JRE for distribution
How to make a follow function in Rails
[Java] How to make multiple for loops single
How to make an app with a plugin mechanism [C # and Java]
[Java] How to use Map
How to lower java version
[Java] How to use Map
How to uninstall Java 8 (Mac)
How to use java Optional
How to minimize Java images
How to write java comments
How to leave a comment
How to use java class
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to display Wingdings
[Java] How to use string.format
How to use Java Map
[Java] Make it a constant
How to set Java constants
How to use Java variables
How to convert Java radix
[Rails] How to make seed
[Java] How to implement multithreading
[Java] How to use Optional ①
How to initialize Java array
How to insert a video
Make a rhombus using Java
How to create a method
How to make a factory with a model with polymorphic association
How to create a Java environment in just 3 seconds
How to jump from Eclipse Java to a SQL file
java: How to write a generic type list [Note]
[Java] How to play rock-paper-scissors (equivalent to paiza rank A)
How to make Java unit tests (JUnit & Mockito & PowerMock)
How to make JavaScript work on a specific page
How to create a data URI (base64) in Java
[Java] How to get a request by HTTP communication
I tried to make a login function in Java
[Java] How to execute tasks on a regular basis