How to Solve Error Template parsing error: template: :1: unclosed action when running a Docker Command to get IP Address of a running Docker Container

Posted on

Introduction

This article has a relation with the previous article about getting the IP address of a running docker container. That article exist in this link with the title of ‘How to get IP Address of a Running Docker Container’. Actually, upon executing a command to get IP address of a running docker container, the error as exist in the title of this article appear. The error exist upon executing the following command as follows :

C:\Users\Administrator\Downloads>docker inspect --format '{{ .NetworkSettings.IPAddress }}' mycontainer
Template parsing error: template: :1: unclosed action

C:\Users\Administrator\Downloads>

Apparently, although the format or the syntax of the command for getting the IP address is correct, it still generate an error message. So, this article will discuss on how to solve the error and get the IP address of the running docker container. Moreover, the docker container is running in a host using Microsoft Windows as its operating system.

Solution

Basically, the error has a very simple solution. After searching through Google to find out the reason. It actually exist in this link. One of the comment available on that link which is a stackoverflow post is giving the answer. Actually, in Microsoft Windows, the format parameter’s value cannot use a single quote.  It must use double quote to enclose the value of the format parameter. On the other hand, in other operating system, it is the right syntax to use single quote. Since the command run in a host using Microsoft Windows as its operating system, just revise the above command and execute it once more as follows :

C:\Users\Administrator\Downloads>docker inspect --format "{{ .NetworkSettings.IPAddress }}" mycontainer
172.17.0.3

C:\Users\Administrator\Downloads>

It is actually exist in this link which available as the previous article. It is an article with the title of ‘How to get IP Address of a Running Docker Container’. As in the above command execution, after revising the command by using double quote, the result appear. It is giving the IP address of the running docker container.

Leave a Reply