Hi,
I tried dockerizing a simple plumber API using a programmatic definition. Here is the index.R
script I am using:
#!/usr/bin/env Rscript
suppressMessages(library(jsonlite))
suppressMessages(library(plumber))
pr <- plumber$new()
pr$handle("GET", "/", function(req, res) {
"Hello, this is Plumber!"
})
pr$run(port=8081)
The Dockerfile
looks like this:
FROM trestletech/plumber
RUN addgroup --system app && adduser --system --ingroup app app
WORKDIR /home/app
COPY index.R .
RUN chown app:app -R /home/app
USER app
EXPOSE 8081
ENTRYPOINT ["Rscript", "index.R"]
I can build a Docker image by docker build -t <image_name> .
and run it as docker run -p 80:8081 <image_name>
, then I get Starting server to listen on port 8081
as expected. But when I go to localhost
I get no response.
I must be missing something trivial here.