RUN echo '[local]\nlocalhost\n' > /etc/ansible/hostsThis line is in my dockerfile, and I assume it just means add localhost to the ansible/hosts file?Can someone break down what [local]\nlocalhost\n is in a bit more detail so that a newb could understand?
What exactly is echo '[local]\nlocalhost\n' > /etc?
linux;shell;docker
This line tells Docker to run the shell command: echo '[local]\nlocalhost\n' > /etc/ansible/hostsThat shell command will print the following text block in the file /etc/ansible/hosts:[local]localhostIt does this because \n is the newline character, signaling the beginning of a new text line. That means that echo has been instructed to do the following: print the text [local], then start a new line, print localhost, and finally start another new line. This output is redirected using the special > character, and the destination after redirection is specified as /etc/ansible/hosts. While that file may not have a .txt extension, you can think of it as a plain text file.That file is probably specified  because it is used by Ansible to communicate with different hosts (in this case localhost) through its inventory functionality.So yes, you were essentially correct -- this adds localhost to the Ansible hosts file. It's worth noting that this command will overwrite any existing file at /etc/ansible/hosts.