I'm trying to get the docker images
command output to display it on a webpage.
As you can see on the image, this is well formatted.
But what I get on my web page is one line not formatted at all;
REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 3448f27c273f 2 days ago 109.4 MB mysql latest e799c7f9ae9c 3 days ago 407.3 MB
This my script at the moment;
docker_images=$(docker images)
echo $docker_images
How can I get the well formatted output through my echo ?
So I tried an echo nl2br($output)
which gave me this;
This is a bit better but still not well formatted. Any ideas how to improve this ?
Edit :
This is working now, i'm getting the output that I want. I juste had to do this;
echo "<pre>";
echo nl2br($output) or $output;
echo "</pre>";
Well it is in plain text. If anyone want to manipulate these, you can use the docker API. https://docs.docker.com/engine/api/v1.24/