Understanding code executed after run command in Docker

I just saw the below script in the Docker doc’s.

$ docker restart db
db
$ docker run -t -i --rm --link db:db training/webapp /bin/bash
root@aed84ee21bde:/opt/webapp# cat /etc/hosts
172.17.0.7  aed84ee21bde
. . .
172.17.0.9  db

What is happening after the run cammand is executed ? , the below part i mean:

  • Running a Docker image in PyCharm causes “Invalid volume specification”
  • Docker containers and Node.js clusters
  • Namenode runs on InternalIP:8020 in cloudera docker and causes applications to fail
  • How to obtain container Ip from another container?
  • Docker using mysql
  • oauth2client.client.AccessTokenRefreshError: invalid_grant Only in Docker
  • root@aed84ee21bde:/opt/webapp# cat /etc/hosts 
    

    Can somebody explain this line by line, I fail to understand. Please this is really important to me.

  • In a Dockerfile, How to update PATH environment variable?
  • systemd not waiting for my service unit to finish before starting the next one
  • How to notify application about updated config file in kubernetes?
  • Bad assignment of IPs with custom bridge in docker 1.6
  • Dockerfile COPY: “lchown … not a directory”
  • lstate error: no such file or directory while building Docker from a custom image with Docker build command
  • One Solution collect form web for “Understanding code executed after run command in Docker”

    docker run -t -i --rm --link db:db training/webapp /bin/bash
    

    This line executes the command /bin/bash in a container created from the image training/webapp. /bin/bash is an interactive shell, and so executing it means that you’re now in a shell inside the fake machine that is the Docker container. root@aed84ee21bde:/opt/webapp# is the shell’s prompt, indicating that you are root on host aed84ee21bde with current directory /opt/webapp. cat /etc/hosts means the same thing here that it does outside the container, except that here it’s referring to the /etc/hosts file inside the container, which is likely different from the one on your main system.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.