Skip to content

Alexlloydwhite/docker-example-java-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello World

This is a Hello World app. The backend is Java / Micronaut and the frontend is TypeScript / React.
It is fully tested (Jest / Spock) and containeried with Docker. There is a Gitbub Actions workflow to run tests and deploy to Dockerhub.

Future Enhancements

  • Github Actions deploys to AWS
  • Create a database to store the docker message

Containers

A predictable, consistent, and reliable environment.

A box that contains everything an application needs to run (source code, dependencies, run environment, OS, etc). This container can run the application in isolation. Everything the app needs to run is in the container.

Containers VS Virtual Machines

  • Virtual Machines
    Has it's own full operating system & typically slower
  • Containers
    Share the host's operating system & typically quicker

Images

Containers are built using an Image. Images are made up from several "layers". When docker builds an image, it stores each layer in a cache. So, building subsequent images will become faster!

Parent Image

Includes the OS & sometimes the runtime environment

Child Images

Built on top of the parent image. Parent Image -> Source Code -> Dependencies -> Run Commands

Using Docker from the Terminal

Building an Image

docker build -t myapp2 .

Starting a container

docker run --name myapp_c1 -p 4000:4000 -d myapp

--name sets the name of the container
-p plus local port:container port
-d to not block the terminal
name of image

Stopping a Container

docker stop containerName
docker stop containerId

Managing Containers and Images

View all running containers:

docker ps

View all containers (including non running containers):

docker ps -a

View all images:

docker images

Deleting an image:

docker image rm imageName

Deleting an image that has a running container

docker image rm imageName -f

Deleting a container

docker container rm containerName

Deleting multiple containers

docker container rm containerName containerName2 containerName3

About

Hello World app with Docker, Java, React, and Github Actions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published