Understanding code executed after run command in Docker

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

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

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

  • How should I combine docker containers?
  • How to enable Virtualisation on Windows 8?
  • How to set up Hadoop in Docker Swarm?
  • Docker: how to see output/error of CMD [ “python”, “./some_python.py” ]
  • ssh from docker gets stuck without any error
  • How to Use go Daddy SSL Certificates for Docker TLS
  • 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.

  • Pycharm 2016.1.4 (newest) and Docker issue
  • Docker and Angular app: one or two containers?
  • Docker containers cannot connect through overlay networks
  • Mongodb on samba shared directory
  • HTTP Call to Docker Container redirects IP to Docker ID
  • Is it possible to launch a new Docker container from within a running Docker container using Docker Compose?
  • 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.