tree: b0e1b5e1ab7df9a637c13430e07f8e0e16573c19 [path history] [tgz]
  1. .dockerignore
  2. Dockerfile

Docker Image for ANTLR4

This Docker image wraps current version of ANTLR4 inclusive Java runtime environment so it can be executed as transparent command line tool even on machines without installed Java.

Docker Image

The image uses the official eclipse-temurin:11 image for building a distribution of ANTLR4 and eclipse-temurin:11-jre for runtime.


You can build docker image from source code locally.

git clone
cd antlr4/docker
docker build -t antlr/antlr4 --platform linux/amd64 .


For security reasons is ANTLR4 Docker image designed to run in the current folder only, so a container doesn't have any access to any other folders on a host system. Since this is a transparent call of Docker image from command line, where new files are generated, it is also a good idea to execute code inside a Docker as a non root user and match it to the host caller.

Calling a dockerized ANTLR4 image can look like this:

docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) -v `pwd`:/work antlr/antlr4 -Dlanguage=Go JSON.g4

Integration as alias

  alias antlr4='docker run -it -u $(id -u ${USER}):$(id -g ${USER}) -v $(pwd):/work antlr/antlr4 $@'