How can I plot an image with javascript, which I saved before in the docker workdir?

I’m running a docker container and inside this container, I’m saving an image to the workdir of the container. I want to plot this image on a website with javascript. Inside the container, is a flask service running.

Saving the plot to the workdir of the docker container:

plt.savefig('/app/TrainingAccLoss.png')

my Dockerfile:

# Use an official Python runtime as a parent image
FROM python:3.5

# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]

Try to plot the image:

var img = document.createElement("img");
img.src = "/app/TrainingAccLoss.png";
document.body.appendChild(img);

When I’m trying to plot the image, I got an 404 Error.

GET http://localhost:4000/app/TrainingAccLoss.png 404 (NOT FOUND).

I don’t know if there is a possibility to access a file which is inside the workdir.

Source: StackOverflow