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:

  • docker swarm 1.12 --name option not recognized
  • use docker-client api to start container in Java project
  • use cloudera with docker-compose
  • Starting mysql container using docker machine with virtual box shared folder
  • Docker Volume not saving
  • Docker HaProxy exposed ports
  • 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.

  • docker-compose build and http_proxy
  • Possible to http clone repo to Docker Container?
  • Docker confusion
  • Cant build a docker dart-runtime image after a local pub-get
  • Why I receive permission denied in Docker deployment?
  • How do I reload haproxy.cfg on the default Dockerfile?
  • 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.