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:

  • Invalid Message Format on Postgresql using Docker
  • Docker Container Networking with Docker-in-Docker
  • Docker / Postgres: Mounting an existing database within a dockerized Postgresql
  • docker Mule-server curl: (56) Recv failure: Connection reset by peer
  • Mount (link) a single file from a docker container volume
  • Why is the loop-lvm device storage not suitable for production?
  • 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.

  • How to prevent Dockerfile caching git clone
  • Get MAC address of other host on network from Docker container
  • NFS or mounting shares with docker
  • Jenkins returned status code 128 with docker
  • Run MySQL on different port with different config
  • Content of a dockerfile to run glassfish server and deploy specific application from a git repository
  • 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.