How to run an init script for Docker MariaDB

The official Docker mariadb image will run all *.sh and *.sql scripts in its /docker-entrypoint-initdb.d directory automatically when it starts. Table of contents: 1. Create an init.sql 2. Run an init script for Docker MariaDB 3. Access the MariaDB running container 4. References Technologies used: Docker 24.0.5 Official Docker mariadb image (latest tag) 1. Create …

Read more

Docker – Running MariaDB as a container

This article shows how to use Docker to run MariaDB as a container. Tables of contents: 1. Run MariaDB as a container 2. Specify the MariaDB version 3. Access the running MariaDB container 4. MariaDB Persistent Storage with Volume 5. Access the MariaDB container log 6. Stop the MariaDB Container 7. Start the MariaDB Container …

Read more

How to run an init script for Docker Postgres

The official Docker postgres image will run all *.sh and *.sql scripts in its /docker-entrypoint-initdb.d directory automatically when it starts. Table of contents: 1. Create an init.sql 2. Copy init.sql to container 3. Start the Postgres container 4. Access the Postgres container 5. References Technologies used: Docker 24.0.5 Official Docker postgres image (latest) 1. Create …

Read more

Spring Boot Testcontainers Example

This article shows how to test the Spring Boot REST endpoints using TestRestTemplate and Testcontainers (PostgreSQL container). Technologies used : Spring Boot 3.1.2 (Spring Web MVC, Spring Data JPA and Spring Test) Testcontainers 1.19.0 PostgreSQL 15, Alpine Linux base image postgres:15-alpine Java 17 JUnt 5 Tables of contents: 1. Project Structure 2. Project Dependencies 3. …

Read more

Gradle + Quarkus Hello World example

This article shows how to create or scaffold a Gradle + Quarkus JAX-RS hello world project, which creates a /hello endpoint and returns a string. Technologies used: Quarkus 1.11.0 Gradle 6.7 Maven 3.6.3 Java 11 Topics Creating a new Gradle + Quartus project Gradle + Quarkus Project Structure Quarkus and build.gradle Quarkus Dependencies (runtimeClasspath) Quarkus …

Read more

Maven + Quarkus Hello World example

This article shows how to use the quarkus-maven-plugin to create or scaffold a Maven + Quarkus JAX-RS hello world project. Technologies used: Quarkus 1.11.0 Maven 3.6.3 Java 11 Topics Creating a new Maven + Quartus project Maven + Quarkus Project Structure Quarkus and pom.xml Quarkus Dependencies Quarkus JAX-RX endpoint Quarkus and Dockerfile Run Quarkus in …

Read more

What is docker –rm option

On Docker, –rm option means automatically remove the container when it exits. $ docker run –rm <container_id> Done 🙂 Please read on to understand more about –rm. 1. Remove a container On Docker, the container is an instance of an image, and we can create multiple containers from an image. If the container is exited …

Read more

How to list containers in Docker?

In Docker, we can use docker ps to show all running containers, docker ps -a to show all running and stopped containers. Here are some of the commonly used examples: Terminal # common $ docker ps // show only running containers $ docker ps -a // show all containers (running and stopped or exited) # …

Read more

Docker run but no output?

docker run a container, but it displayed nothing, no output, no error? docker ps shows no running container? Terminal $ docker run -d -p 80:8080 -p 443:8443 -t markdownhtml:1.1 8eba06d44bf236109cf65b7b93842e9c898370cac1740aa2bab557a0fc8e52b9 $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES Solution Most of the time, the container hit an error and exited automatically. We …

Read more

Java 11 – Java Flight Recorder

Java Flight Recorder (JFR) is a Java profiling tool that used to monitor and diagnose a running Java application, it collects data about the running environment, JVM and Java application and dumps the recorded data into a .jfr file, and we can use Java Mission Control (JMC) to analyze and visualize the .jfr file. Tested …

Read more

Docker – exec: "bash": executable file not found in $PATH

If bash shell is not working, try sh. Terminal $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3d1588519433 markdownhtml:0.1 "java -jar app.jar" About an hour ago Up About an hour 0.0.0.0:80->8080/tcp gracious_haibt $ docker exec -it 3d1588519433 bash OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"bash\": executable …

Read more

Java – jcmd not found?

The jcmd is available at the JDK/bin, not JRE. Make sure the installed Java is JDK, not JRE. Let review the following example, try to use jcmd to enable Java Flight Recorder inside a docker container. 1. DockerFile A simple Dokcerfile. Dockerfile FROM adoptopenjdk/openjdk11:alpine-jre ARG JAR_FILE=target/markdown.jar WORKDIR /opt/app COPY ${JAR_FILE} app.jar ENTRYPOINT ["java","-jar","app.jar"] 2. Docker …

Read more

How to stop and remove all docker containers?

In Docker, we cannot remove a running container, stop it first. Stop all running containers. Terminal $ sudo docker stop $(sudo docker ps -aq) Remove all stopped containers. Terminal $ sudo docker rm $(sudo docker ps -aq) 1. Stop Container 1.1 List all containers sudo docker ps Terminal $ sudo docker ps CONTAINER ID IMAGE …

Read more

Docker + Spring Boot examples

In this tutorial, we will show you how to Dockerize a Spring Boot web application (mvc + thymeleaf). Tested with Docker 19.03 Ubuntu 19 Java 8 or Java 11 Spring Boot 2.2.4.RELEASE Maven At the end of the article, we will create a Spring Boot MVC web application and run inside a docker container. P.S …

Read more

Spring Boot + Spring Data JPA + PostgreSQL example

This article shows how to use Spring Web MVC to create REST endpoints for CRUD database operations using the Spring Data JPA and PostgreSQL. At the end of the tutorial, we will use Docker to start a PostgreSQL container to test the Spring Boot REST endpoints using curl commands. We will use Spring Test and …

Read more

Spring Boot + Spring Data JPA + MySQL example

This article shows how to use Spring Web MVC to create REST endpoints to perform CRUD database operations using the Spring Data JPA and MySQL. At the end of the tutorial, we will use Docker to start a MySQL container to test the Spring Boot REST endpoints using curl commands. We will use Spring Test …

Read more