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:
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.
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.