Docker. How to get bash\ssh inside running container (run -d)?

source: http://askubuntu.com/a/507009/89694

$ sudo docker attach 665b4a1e17b6 #by ID
or
$ sudo docker attach loving_heisenberg #by Name
$ root@665b4a1e17b6:/# 

UPDATE: (docker >= 1.3) Thanks to WiR3D user who suggested another way to get container’s shell. If we use attach we can use only one instance of shell. So if we want open new terminal with new instance of container’s shell, we just need run the following:

$ sudo docker exec -i -t 665b4a1e17b6 bash #by ID
or
$ sudo docker exec -i -t loving_heisenberg bash #by Name
$ root@665b4a1e17b6:/#

 

 

Precedence for the Commandline $PATH

On the commandline the elements of PATH are checked from left to right.

an example (PATH)

the command test-my-command-precedence.sh which exists in
/bin/test-my-command-precedence.sh
/usr/bin/test-my-command-precedence.sh

for the following path

~/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

the /usr/bin/test-my-command-precedence.sh gets precedence.

bash redirect output STDOUT STDERR

HOWTO redirect output: STDOUT / STDERR

Examples:

output or stdout to screen
$ echo "test"

redirects stdout to afile.txt
$ echo "test" > afile.txt

  • 0 is stdin.
  • 1 is stdout.
  • 2 is stderr.

also redirects stdout to afile.txt
$ echo "test" 1> afile.txt

redirect stderr to afile.txt
$ echo "test" 2> afile.txt

>& is the syntax to redirect a stream to another file descriptor

redirect stdin to stderr
$ echo "test" 1>&2
# or
$ echo "test" >&2

..or vice versa:

$ echo "test" 2>&1

So, in short.. 2> redirects STDERR to an (unspecified) file, appending &1 redirects STDERR to STDOUT